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 Client local mode (chef zero) search inconsistencies (NOT / AND NOT) #150

Open
petecheslock opened this issue Jul 29, 2015 · 3 comments
Labels
Aspect: Search Type: Bug Does not work as expected.

Comments

@petecheslock
Copy link

This is with both Chef 12.0.0 and 12.1.1

When talking to a real chef server (in that case hosted chef) - and running the following queries. I get the following results (there are about 60 other nodes in this hosted chef account).

chef > search(:node, "role:api_server AND chef_environment:#{node.chef_environment} NOT tags:hidden", :filter_result => { 'ip' => ['ipaddress'] })
 => [{"ip"=>"1.1.1.1"}]
chef > search(:node, "role:api_server AND chef_environment:#{node.chef_environment} AND NOT tags:hidden", :filter_result => { 'ip' => ['ipaddress'] })
 => [{"ip"=>"1.1.1.1"}]

Works as I would expect

Also here i'm using filter results - but have confirmed the issue with both normal search and "partial" search.

On a test server - (using test-kichen with chef zero provisioner), and pre-populating node data, I see the following:

Node Data

cat /tmp/kitchen/nodes/api_server.json
{
  "id": "api_server",
  "chef_environment": "test",
  "run_list": [
    "role[api_server]"
  ],
  "automatic": {
    "ipaddress": "172.33.33.34",
    "hostname": "api-server",
    "roles": [
      "api_server"
    ]
  }
}
{
  "id": "sensu_master",
  "chef_environment": "test",
  "run_list": [
    "role[sensu_master]"
  ],
  "automatic": {
    "ipaddress": "172.33.33.50",
    "hostname": "sensu-master",
    "roles": [
      "sensu_master"
    ]
  }
}

Then running queries against:

pry(#<Chef::Recipe>)> search(:node, "role:api_server AND chef_environment:#{node.chef_environment} NOT tags:hidden", :filter_result => { 'ip' => ['ipaddress'] })
=> [{"ip"=>"172.33.33.34"},{"ip"=>"172.33.33.50"}]
pry(#<Chef::Recipe>)> search(:node, "role:api_server AND chef_environment:#{node.chef_environment} AND NOT tags:hidden", :filter_result => { 'ip' => ['ipaddress'] })
=> [{"ip"=>"172.33.33.34"}]
pry(#<Chef::Recipe>)> search(:node, "role:api_server AND chef_environment:#{node.chef_environment}", :filter_result => { 'ip' => ['ipaddress'] })
=> [{"ip"=>"172.33.33.34"}]

So in this case it seems to be the AND or AND NOT at the end. This is easy for us to work around by using AND NOT in our cookbooks since that seems to work for both, but there might be a chef-zero or localmode bug.

@thommay
Copy link
Contributor

thommay commented Aug 2, 2016

I suspect this is another instance of #92 - @petecheslock if you do "role:api_server AND chef_environment:#{node.chef_environment} OR NOT tags:hidden" do you still get both nodes returned?

@petecheslock
Copy link
Author

@thommay yea - same thing (using latest 12.12.15 version of chef), if I do the query: role:api_server AND chef_environment:#{node.chef_environment} OR NOT tags:hidden then both nodes are still returned.

@lamont-granquist lamont-granquist added this to the Accepted Minor milestone Dec 14, 2016
@thommay thommay added Type: Bug Does not work as expected. and removed bug labels Jan 24, 2017
@chilicheech
Copy link

I just hit this bug too. In solr as far as I can tell the proper search query is: role:A AND chef_environment:B NOT tags:C. That NOT behaves as an AND NOT. However, that NOT seems to behave as an OR NOT in chef-zero instead. I'm able to workaround the issue by replacing the NOT with AND NOT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Aspect: Search Type: Bug Does not work as expected.
Projects
None yet
Development

No branches or pull requests

4 participants