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

Chef 12.0.1 Fails To knife exec Any Script #2609

Closed
sean-horn opened this issue Dec 10, 2014 · 4 comments · Fixed by #2610
Closed

Chef 12.0.1 Fails To knife exec Any Script #2609

sean-horn opened this issue Dec 10, 2014 · 4 comments · Fixed by #2610
Labels
Type: Bug Does not work as expected.
Milestone

Comments

@sean-horn
Copy link
Contributor

This appears to be related to the same root Chef Client issue as chefspec/chefspec#534

Running the identical simple knife exec script with Chef 12.0.1 fails, and succeeds with Chef 11.12.2

$ knife --version
Chef: 12.0.1

$ knife exec -E 'nodes.all {|n| puts "#{n.name} has #{n.memory.total} free memory"}'
/opt/chef/embedded/apps/chef/lib/chef/resource/file.rb:29:in `<class:File>': undefined method `identity_attr' for Chef::Resource::File:Class (NoMethodError)
    from /opt/chef/embedded/apps/chef/lib/chef/resource/file.rb:26:in `<class:Resource>'
    from /opt/chef/embedded/apps/chef/lib/chef/resource/file.rb:25:in `<class:Chef>'
    from /opt/chef/embedded/apps/chef/lib/chef/resource/file.rb:24:in `<top (required)>'
    from /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /opt/chef/embedded/apps/chef/lib/chef/provider/file.rb:22:in `<top (required)>'
    from /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /opt/chef/embedded/apps/chef/lib/chef/provider/cookbook_file.rb:19:in `<top (required)>'
    from /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /opt/chef/embedded/apps/chef/lib/chef/providers.rb:21:in `<top (required)>'
    from /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /opt/chef/embedded/apps/chef/lib/chef/platform/provider_priority_map.rb:2:in `<top (required)>'
    from /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /opt/chef/embedded/apps/chef/lib/chef/provider_resolver.rb:20:in `<top (required)>'
    from /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /opt/chef/embedded/apps/chef/lib/chef/resource.rb:32:in `<top (required)>'
    from /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /opt/chef/embedded/apps/chef/lib/chef/dsl/recipe.rb:157:in `<top (required)>'
    from /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /opt/chef/embedded/apps/chef/lib/chef/recipe.rb:21:in `<top (required)>'
    from /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /opt/chef/embedded/apps/chef/lib/chef/shell/ext.rb:20:in `<top (required)>'
    from /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /opt/chef/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /opt/chef/embedded/apps/chef/lib/chef/knife/exec.rb:37:in `block in <class:Exec>'
    from /opt/chef/embedded/apps/chef/lib/chef/knife.rb:254:in `call'
    from /opt/chef/embedded/apps/chef/lib/chef/knife.rb:254:in `block in load_deps'
    from /opt/chef/embedded/apps/chef/lib/chef/knife.rb:253:in `each'
    from /opt/chef/embedded/apps/chef/lib/chef/knife.rb:253:in `load_deps'
    from /opt/chef/embedded/apps/chef/lib/chef/knife.rb:210:in `run'
    from /opt/chef/embedded/apps/chef/lib/chef/application/knife.rb:139:in `run'
    from /opt/chef/embedded/apps/chef/bin/knife:25:in `<top (required)>'
    from /usr/bin/knife:40:in `load'
    from /usr/bin/knife:40:in `<main>'

If I run from the embedded Chef 11.12.2, no problem

$ /opt/opscode/embedded/bin/knife --version
Chef: 11.12.2

[vagrant@centos-6 ~]$ /opt/opscode/embedded/bin/knife exec -E 'nodes.all {|n| puts "#{n.name} has #  {n.memory.total} free memory"}'
vagrant.hsd1.wa.comcast.net. has 376260kB free memory
chef.onefour.com has 469800kB free memory
centos-6.5 has 469452kB free memory
bumpytoes has 376236kB free memory
@sean-horn sean-horn added the Bug label Dec 10, 2014
@jaym
Copy link
Contributor

jaym commented Dec 10, 2014

Thanks, looks like a cyclic dependency. @sersut seems to have found it

@sersut
Copy link
Contributor

sersut commented Dec 10, 2014

The issue here is that lib/chef/resource.rb:32 requires provider_resolver and after a chain of requires, lib/chef/resource/file is required which tries to set the identity_attr but it can't because the require in lib/chef/resource didn't get far enough to define that method yet.

We should definitely fix this in 12.0.2.

@sersut sersut added this to the 12.0.2 milestone Dec 10, 2014
@lamont-granquist
Copy link
Contributor

Hard to say exactly where to fix it right without some major refactoring because the priority map is necessarily tightly coupled to the providers themselves, which are tightly coupled to the resources via load_current_resource, and the resource base class itself is tightly coupled to the provider_resolver which needs the priority_map.

@sean-horn
Copy link
Contributor Author

This issue with knife exec ... can potentially be worked around by placing require 'chef/provider_resolver' after the other requires in /opt/chef/embedded/apps/chef/lib/chef/knife.rb in a Chef Client 12.0.1 installation

@thommay thommay added Type: Bug Does not work as expected. and removed Bug labels Jan 25, 2017
@chef chef locked and limited conversation to collaborators Nov 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Bug Does not work as expected.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants