Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PE-38948) Respect rich_data in compileCatalog #2875

Merged
merged 1 commit into from
Sep 11, 2024

Conversation

justinstoller
Copy link
Member

@justinstoller justinstoller commented Sep 3, 2024

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 and
serializing 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 has
configured (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.

@justinstoller
Copy link
Member Author

Just for show right now.

@justinstoller justinstoller changed the title (maint) Show Puppet.lookup(:rich_data) returns false (PE-38948) Respect rich_data in compileCatalog Sep 9, 2024
@justinstoller
Copy link
Member Author

The test failures seem to be a product of a newer JVM 17 verses the main branch. Here are the same failures without the code changes #2876, which I'm looking into but shouldn't' block this.

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 and
serializing 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 has
configured (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.
@mcdonaldseanp mcdonaldseanp merged commit bbec082 into puppetlabs:main Sep 11, 2024
11 checks passed
@justinstoller justinstoller deleted the thats_rich branch September 11, 2024 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants