(PE-38948) Respect rich_data in compileCatalog #2875
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, when using the compileCatalog method of
Puppet::Server::Master compilation would fail to serialize rich data.
This occurred because during serialization we introspect the
Puppet.context for the rich_data value (the setting itself defaults to
true & and strict now defaults to error, throwing an error when we
encounter an object that requires rich_data to serialize).
Normal catalog compilation works because the value of rich_data in the
Puppet.context is overridden by the caller of the serialization code for
indirected routes, using whatever is set in the environment and if unset
in the environment then falling back to the actually rich_data setting.
In the compileCatalog method however we do not use the indirected routes
for serialization, instead calling
to_data_hash
on the catalog andserializing that ourselves (we explicitly only support JSON via that
endpoint). This means the value in the Puppet.context is the default
value which at the present is
false
regardless of what the user hasconfigured (or our own settings defaults).
This commit attempts to fix this by overriding the Puppet.context's
rich_data value with the Puppet setting for rich_data. Which now
defaults to true and will honor whatever the user puts in their
puppet.conf. This however does not support rich_data per environment. I
believe the optimal point to override rich_data is at the overall
compileCatalog level but we do not have the "current" environment at
that point, neccessitating a much larger rewrite of the compileCatalog
function to work. The fact that you can even set rich_data in the
environment.conf at this time is an undocumented feature, which leads me
to believe a larger rewrite of the compileCatalog function is not
a good investment.