-
Notifications
You must be signed in to change notification settings - Fork 230
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
(PDB-4945) Default to json fact cache #312
Conversation
Puppetserver 7 now defaults the fact cache to json[1]. When running in
agent-server mode, configure routes.yaml the same way. There is no change in
behavior when running with puppetserver < 7 or `puppet apply`.
As a result of this change, when the puppetdb module is used to install the
puppetdb terminus and routes.yaml, facts will now be cached as non-pretty json
in:
/opt/puppetlabs/server/data/puppetserver/server_data/facts/<node>.json
Instead of pretty yaml in:
/opt/puppetlabs/server/data/puppetserver/yaml/<node>.yaml
The difference in pathing is due to the abstract yaml and json termini using
different base directories in which to store data: `Puppet[:yamldir]` vs
`Puppet[:server_data]`.
[1] https://github.com/puppetlabs/puppetserver/blob/794e725628545aa075e3f8b5fa91f21628373594/src/ruby/puppetserver-lib/puppet/server/puppet_config.rb#L56
puppetdb::master::routes is a classthat may have no external impact to Forge modules. This module is declared in 33 of 575 indexed public
|
manifests/master/routes.pp
Outdated
| @@ -22,7 +22,7 @@ | |||
| } elsif $routes { | |||
| $routes_real = $routes | |||
| } else { | |||
| if versioncmp($serverversion, '7.0') == -1 { | |||
| if (defined('$serverversion')) and (versioncmp($serverversion, '7.0') == 1) { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we still want -1 here so we use yaml on < 7.0:
$ bx puppet apply -e "notice(versioncmp('6.19', '7.0'))"
Notice: Scope(Class[main]): -1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
Now if serverversion is defined and if the version is greater than 7.0, we're going to prefer json. If not we're going to prefer yaml
273b150
to
58e61f5
Compare
58e61f5
to
8a722ac
Compare
|
With environment variables: I installed puppetdb using puppetserver CI: At this point there are json facts cached in the new place (due to agents running prior to the old puppetdb being installed): Then I copied a build of this module to the server: The cron_core issue is fixed in puppetlabs/puppetlabs-cron_core@ae6c349 Since the old terminus is in effect when the agent gets its catalog, the server writes facts as yaml to the old place: And from that point forward, the json facts are updated with each run: |
With the change introduced in puppetlabs#312 this module switches the fact cache type if the puppetserver it's running against is v7 or greater; in that situation it will use the puppetserver v7 default of `json` for the fact cache format. Unfortunately this opens up the possibility that while the server a puppet-agent is running against might be v7, the agent and the server it's running to configure might not be. Specifically, we hit a situation where a server hosting puppetserver 5 was running puppet-agent against another puppetserver on version 7 (this was for the purposes of a version rollout), with the result that this module configured the puppetserver v5 with a fact cache format of `json`, signalling the puppetserver v5 to restart and meaning it failed during startup. I think the intention of the original change was to switch its behaviour based on the version of puppetserver it's configuring, and not necessarily the version of puppetserver it's running against. Given the puppetserver compatibility requirements I believe it's safe to use the puppet-agent version as an analogue for the local puppetserver version, so here I'm using the `clientversion` fact to replace `serverversion`.
Puppetserver 7 now defaults the fact cache to json[1]. When running in
agent-server mode, configure routes.yaml the same way. There is no change in
behavior when running with puppetserver < 7 or
puppet apply.As a result of this change, when the puppetdb module is used to install the
puppetdb terminus and routes.yaml, facts will now be cached as non-pretty json
in:
Instead of pretty yaml in:
The difference in pathing is due to the abstract yaml and json termini using
different base directories in which to store data:
Puppet[:yamldir]vsPuppet[:server_data].[1] https://github.com/puppetlabs/puppetserver/blob/794e725628545aa075e3f8b5fa91f21628373594/src/ruby/puppetserver-lib/puppet/server/puppet_config.rb#L56