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

Broken JSON module #452

Closed
shamil opened this issue Nov 8, 2018 · 10 comments
Closed

Broken JSON module #452

shamil opened this issue Nov 8, 2018 · 10 comments
Labels
needs-feedback Further information is requested

Comments

@shamil
Copy link

shamil commented Nov 8, 2018

With latest version (5.x) of this module I can't any longer use JSON module.

Seems like after #444 the JSON module is no longer usable outside the consul::sorted_json function.
Seems like overriding modules with The modern Ruby functions API causing problems.

@shamil
Copy link
Author

shamil commented Nov 12, 2018

@solarkennedy can you please verify or prove me wrong? 😃

@bastelfreak
Copy link
Member

Hi @shamil, do you run in a particular issue? If so which version of puppet/ruby do you use and how do you call the module? I use the latest version in production and it works well.

@bastelfreak bastelfreak added the needs-feedback Further information is requested label Nov 13, 2018
@shamil
Copy link
Author

shamil commented Nov 13, 2018

Hi @shamil, do you run in a particular issue? If so which version of puppet/ruby do you use and how do you call the module? I use the latest version in production and it works well.

Hi @bastelfreak ,

The module itself works well, but it cause problems to other puppet functions that make use of JSON module.

For example, the following will throw exception, something about no parse method in JSON module.

require 'json'

Puppet::Functions.create_function(:test_func) do
  def test_func
    JSON.parse('{"foo": "bar"}')
  end
end

If I revert consul module to previous version, the above function works !

@solarkennedy
Copy link
Contributor

Huh. Can you confirm again exactly what version fo ruby+puppet you are using?
We do have this JSON module, but I don't know enough ruby to know if there is a namespace collision
https://github.com/solarkennedy/puppet-consul/blob/139a3b7bbf5cabf166ef9e118a5992b63464d783/lib/puppet/functions/consul/sorted_json.rb#L3

@shamil
Copy link
Author

shamil commented Nov 14, 2018

@solarkennedy yes, that what I meant when mentioning about #444, you extending JSON module there.

I'm running puppet 5.5.8 on ruby 2.4.4p296

@bastelfreak
Copy link
Member

bastelfreak commented Nov 15, 2018

I think I just run into this error while using this module + the vault module:

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
Did you mean?  pretty_print (file: /etc/puppetlabs/code/environments/production/modules/vault/manifests/config.pp, line: 30, column: 16) on *
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

@shamil
Copy link
Author

shamil commented Nov 15, 2018

@bastelfreak, exactly same issue I'm experiencing. If you downgrade the consul module everything will work as expected

@shamil
Copy link
Author

shamil commented Dec 4, 2018

@bastelfreak any news about this? Do you need me to provide any other information?

@den-is
Copy link

den-is commented Dec 5, 2018

same here
Puppet enterprise v2017.3.2
Consul module v5.0.0

UPD:
Update to PE v2018.1.5 didn't work

error output

{
   "changed":false,
   "disabled":false,
   "error":true,
   "msg":"puppet did not run",
   "rc":1,
   "stderr":"Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, undefined method `pretty_generate' for Puppet::Pops::Loader::RubyFunctionInstantiator::JSON:Module\nDid you mean?  pretty_print (file: /etc/puppetlabs/code/environments/production/modules/myconsul/manifests/service/logist.pp, line: 44, column: 16) on node i-069fb1137abb7b1e4.logist.aws.intra.com\nWarning: Not using cache on failed catalog\nError: Could not retrieve catalog; skipping run\n",
   "stderr_lines":[
      "Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, undefined method `pretty_generate' for Puppet::Pops::Loader::RubyFunctionInstantiator::JSON:Module",
      "Did you mean?  pretty_print (file: /etc/puppetlabs/code/environments/production/modules/myconsul/manifests/service/logist.pp, line: 44, column: 16) on node i-069fb1137abb7b1e4.logist.aws.intra.com",
      "Warning: Not using cache on failed catalog",
      "Error: Could not retrieve catalog; skipping run"
   ],
   "stdout":"Info: Using configured environment 'production'\nInfo: Retrieving pluginfacts\nInfo: Retrieving plugin\nNotice: /File[/opt/puppetlabs/puppet/cache/lib/puppet/functions/consul]/ensure: removed\nNotice: /File[/opt/puppetlabs/puppet/cache/lib/puppet/parser/functions/consul_sorted_json.rb]/ensure: defined content as '{md5}687479319754f1bedcb84566be25ea5d'\nNotice: /File[/opt/puppetlabs/puppet/cache/lib/puppet/parser/functions/consul_validate_checks.rb]/ensure: defined content as '{md5}e1aa7f61ef9af1ace825b25db4ccb039'\nInfo: Loading facts\n",
   "stdout_lines":[
      "Info: Using configured environment 'production'",
      "Info: Retrieving pluginfacts",
      "Info: Retrieving plugin",
      "Notice: /File[/opt/puppetlabs/puppet/cache/lib/puppet/functions/consul]/ensure: removed",
      "Notice: /File[/opt/puppetlabs/puppet/cache/lib/puppet/parser/functions/consul_sorted_json.rb]/ensure: defined content as '{md5}687479319754f1bedcb84566be25ea5d'",
      "Notice: /File[/opt/puppetlabs/puppet/cache/lib/puppet/parser/functions/consul_validate_checks.rb]/ensure: defined content as '{md5}e1aa7f61ef9af1ace825b25db4ccb039'",
      "Info: Loading facts"
   ]
}

@surcouf
Copy link

surcouf commented Apr 15, 2019

Hi,
I've got the same error...

Puppet 4.8
vault 2.0.0
consul 5.0.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-feedback Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants