sensu / puppet-module-sensuclassic

Puppet module to manage Sensu Classic (ruby version)
MIT License
0 stars 11 forks source link

undefined method `pretty_generate' for Puppet::Pops::Loader::RubyFunctionInstantiator::JSON:Module #24

Closed bastelfreak closed 5 years ago

bastelfreak commented 5 years ago

Description of problem

During a puppet run, I get the following error:

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, undefined method `pretty_generate' for Puppet::Pops::Loader::RubyFunctionInstantiator::JSON:Module (file: /etc/puppetlabs/code/environments/production/modules/vault/manifests/config.pp, line: 30, column: 16) on node vault

to compile into a catalog

It should be enough to do a include vault + having the sensuclassic module in the environment.

Command used and debugging output

There is no sensu related config on the affected machine

master

Platform and version information

Anything else to add that you think will be helpful?

The vault module uses to_json_pretty from stdlib: https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/lib/puppet/functions/to_json_pretty.rb#L75

It basically calls JSON.pretty_generate(). That method is provided by the default json module from the ruby core lib. My guess is that the module JSON overwrites the class from the core lib.

The methods validate_keys(), sorted_generate() and sorted_pretty_generate() should probably extend the json class or stay within the scope of this module?

bastelfreak commented 5 years ago

I did some further digging and I'm not 100% sure if this issue is related to this module. I had a few other environments laying around that contain the consul module before this was merged: https://github.com/solarkennedy/puppet-consul/pull/456. Puppetserver is still not really good at environment isolation.

treydock commented 5 years ago

@bastelfreak I opened #25 just to rule out our monkey patch.

The only environment isolation issues I've run into with Puppetserver is for custom types/providers and that was solved with generating types for each environment when r10k is run.

bastelfreak commented 5 years ago

Thank you very much for the patch. I am happy to test this tomorrow. R10k is called with --generate-types for each run, so types shouldn't be an issue.