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

Search not working in Attributes #8356

Open
bby-bishopclark opened this Issue Apr 11, 2019 · 1 comment

Comments

Projects
None yet
1 participant
@bby-bishopclark
Copy link

commented Apr 11, 2019

Description

This code is no good:

victims=search(:node, 'name:*')

It's about the simplest example I can devise, and while it's working in recipe code it's dying in attributes.

This was suggested in #4235 but closed without confirmation. I could be using it wrongly, and I'm hoping the error message below will show the proof we need.

Chef Version

14.11.21

Platform Version

RHEL 6.10

Client Output

FATAL: NoMethodError: undefined method `search' for #<Chef::Node::Attribute:0x0000000003a5b6f0>

Stacktrace

Generated at 2019-04-11 07:34:48 -0700
NoMethodError: undefined method `search' for #<Chef::Node::Attribute:0x0000000003a5b6f0>
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.11.21/lib/chef/node.rb:263:in `public_send'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.11.21/lib/chef/node.rb:263:in `method_missing'
/var/chef/cache/cookbooks/all-datacenter-attributes/attributes/_remote-rsyslog.rb:8:in `from_file'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.11.21/lib/chef/mixin/from_file.rb:34:in `instance_eval'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.11.21/lib/chef/mixin/from_file.rb:34:in `from_file'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.11.21/lib/chef/dsl/include_attribute.rb:39:in `block in include_attribute'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.11.21/lib/chef/dsl/include_attribute.rb:31:in `each'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.11.21/lib/chef/dsl/include_attribute.rb:31:in `include_attribute'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.11.21/lib/chef/run_context/cookbook_compiler.rb:217:in `load_attribute_file'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.11.21/lib/chef/run_context/cookbook_compiler.rb:209:in `block in load_attributes_from_cookbook'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.11.21/lib/chef/run_context/cookbook_compiler.rb:208:in `each'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.11.21/lib/chef/run_context/cookbook_compiler.rb:208:in `load_attributes_from_cookbook'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.11.21/lib/chef/run_context/cookbook_compiler.rb:135:in `block in compile_attributes'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.11.21/lib/chef/run_context/cookbook_compiler.rb:134:in `each'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.11.21/lib/chef/run_context/cookbook_compiler.rb:134:in `compile_attributes'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.11.21/lib/chef/run_context/cookbook_compiler.rb:76:in `compile'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.11.21/lib/chef/run_context.rb:199:in `load'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.11.21/lib/chef/policy_builder/expand_node_object.rb:97:in `setup_run_context'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.11.21/lib/chef/client.rb:515:in `setup_run_context'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.11.21/lib/chef/client.rb:281:in `run'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.11.21/lib/chef/application.rb:303:in `run_with_graceful_exit_option'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.11.21/lib/chef/application.rb:279:in `block in run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.11.21/lib/chef/local_mode.rb:44:in `with_server_connectivity'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.11.21/lib/chef/application.rb:261:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.11.21/lib/chef/application/client.rb:444:in `run_application'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.11.21/lib/chef/application.rb:66:in `run'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.11.21/bin/chef-client:25:in `<top (required)>'
/usr/bin/chef-client:74:in `load'
/usr/bin/chef-client:74:in `<main>'
@bby-bishopclark

This comment has been minimized.

Copy link
Author

commented Apr 11, 2019

Logging this for an eventual fix.

victims=Chef::Search::Query.new.search(:node, 'name:*')

seems to work in its place for the time being.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.