Coder Social home page Coder Social logo

Comments (12)

mcornick avatar mcornick commented on July 27, 2024

This is with chef-zero 1.5.1 on ruby 1.9.3-p429 - sorry for not mentioning that.

from chef-zero.

mcornick avatar mcornick commented on July 27, 2024

On the other hand, this works:


$ knife search users 'groups:sysadmin NOT action:remove'
1 items found

chef_type: data_bag_item
comment:   Mark Cornick
data_bag:  users
groups:    sysadmin
id:        mark
shell:     /bin/bash

So perhaps it is choking on the AND somehow? This same query against Hosted Chef or an open source Chef 11 server works fine, although http://docs.opscode.com/essentials_search.html does not mention the AND NOT syntax.

from chef-zero.

sethvargo avatar sethvargo commented on July 27, 2024

@jkeiser is this test in pedant? If not, maybe it should be added to prevent a regression. I confirm what @markcornick is reporting.

from chef-zero.

trobrock avatar trobrock commented on July 27, 2024

@markcornick i ran into this also I have a PR open for the users cookbook: sous-chefs/users#27

from chef-zero.

jkeiser avatar jkeiser commented on July 27, 2024

It's worth pointing out that "groups:sysadmin NOT action:remove" is actually equivalent "groups:sysadmin OR NOT action:remove" -- not AND. This is from a reading of the chef-zero code, which was based on a reading of the lucene spec.

Can you check whether "groups:sysadmin OR NOT action:remove" works? That might give us a tiny bit more data.

We need a lot more search query tests in pedant--there are very few.

This is on my radar, but this vacation is turning out to be an extremely busy one.

from chef-zero.

mcornick avatar mcornick commented on July 27, 2024

That's good to know about what x:y NOT z:w expands to - in the case of this cookbook, AND NOT is the desired behavior, not OR NOT.

Anyway, OR NOT works for this query with the above data:

$ knife search users 'groups:sysadmin OR NOT action:remove' -c knife.rb
1 items found

chef_type: data_bag_item
comment:   Mark Cornick
data_bag:  users
groups:    sysadmin
id:        mark
shell:     /bin/bash

from chef-zero.

jkeiser avatar jkeiser commented on July 27, 2024

Confirmed. It looks like this is a precedence error: NOT is binding tighter than :. I'll work up a fix for this (and for the fact that subqueries aren't presently working) ASAP. Might not be till later though.

from chef-zero.

jkeiser avatar jkeiser commented on July 27, 2024

Fixed with a9f0654 ... I think.

I tried a few combinations, but could use some inventive querying--I have to go look at houses tonight and don't have time to write pedant tests ATM. Can someone install latest master and tell me if things are working in general for you? Anything particularly involving a:b in various combinations.

from chef-zero.

jkeiser avatar jkeiser commented on July 27, 2024

If you guys confirm it's working ok in general, I'll button up a release when I get back.

from chef-zero.

mcornick avatar mcornick commented on July 27, 2024

I've tried this and am getting the expected results for groups:sysadmin AND NOT action:remove and groups:sysadmin OR NOT action:remove using data bag items that would match or not match groups:sysadmin and action:remove individually. This looks like the correct fix to me. Thanks for taking vacation time to fix it!

$ cat knife.rb
node_name                "markcornick"
client_key               "/Users/mcornick/.chef/markcornick.pem"
chef_server_url          "http://127.0.0.1:8889"
$ cat mark.json
{
  "groups": [ "sysadmin" ],
  "comment": "Mark Cornick",
  "id": "mark",
  "shell": "/bin/bash"
}
$ knife data bag create users -c knife.rb
Created data_bag[users]
$ knife data bag from file users mark.json -c knife.rb
Updated data_bag_item[users::mark]
$ knife search users 'groups:sysadmin AND NOT action:remove' -c knife.rb
1 items found

chef_type: data_bag_item
comment:   Mark Cornick
data_bag:  users
groups:    sysadmin
id:        mark
shell:     /bin/bash

$ vi mark.json # add "action": "remove"
$ knife data bag from file users mark.json -c knife.rb
Updated data_bag_item[users::mark]
$ knife search users 'groups:sysadmin AND NOT action:remove' -c knife.rb
0 items found

$ vi mark.json # remove "action": "remove", change "sysadmin" to "user"
$ knife data bag from file users mark.json -c knife.rb
Updated data_bag_item[users::mark]
$ knife search users 'groups:sysadmin AND NOT action:remove' -c knife.rb
1 items found

chef_type: data_bag_item
comment:   Mark Cornick
data_bag:  users
groups:    sysadmin
id:        mark
shell:     /bin/bash

$ knife search users 'groups:sysadmin OR NOT action:remove' -c knife.rb
1 items found

chef_type: data_bag_item
comment:   Mark Cornick
data_bag:  users
groups:    sysadmin
id:        mark
shell:     /bin/bash

$ vi mark.json # add "action": "remove" again
$ knife data bag from file users mark.json -c knife.rb
Updated data_bag_item[users::mark]
$ knife search users 'groups:sysadmin OR NOT action:remove' -c knife.rb
0 items found

from chef-zero.

trobrock avatar trobrock commented on July 27, 2024

Awesome I will close my users pull request since this is supported now.
On Jun 26, 2013 5:27 PM, "Mark Cornick" [email protected] wrote:

I've tried this and am getting the expected results for groups:sysadmin
AND NOT action:remove and groups:sysadmin OR NOT action:remove using data
bag items that would match or not match groups:sysadmin and action:removeindividually. This looks like the correct fix to me. Thanks for taking
vacation time to fix it!

$ cat knife.rb
node_name "markcornick"
client_key "/Users/mcornick/.chef/markcornick.pem"
chef_server_url "http://127.0.0.1:8889"
$ cat mark.json
{
"groups": [ "sysadmin" ],
"comment": "Mark Cornick",
"id": "mark",
"shell": "/bin/bash"
}
$ knife data bag create users -c knife.rb
Created data_bag[users]
$ knife data bag from file users mark.json -c knife.rb
Updated data_bag_item[users::mark]
$ knife search users 'groups:sysadmin AND NOT action:remove' -c knife.rb
1 items found

chef_type: data_bag_item
comment: Mark Cornick
data_bag: users
groups: sysadmin
id: mark
shell: /bin/bash

$ vi mark.json # add "action": "remove"
$ knife data bag from file users mark.json -c knife.rb
Updated data_bag_item[users::mark]
$ knife search users 'groups:sysadmin AND NOT action:remove' -c knife.rb
0 items found

$ vi mark.json # remove "action": "remove", change "sysadmin" to "user"
$ knife data bag from file users mark.json -c knife.rb
Updated data_bag_item[users::mark]
$ knife search users 'groups:sysadmin AND NOT action:remove' -c knife.rb
1 items found

chef_type: data_bag_item
comment: Mark Cornick
data_bag: users
groups: sysadmin
id: mark
shell: /bin/bash

$ knife search users 'groups:sysadmin OR NOT action:remove' -c knife.rb
1 items found

chef_type: data_bag_item
comment: Mark Cornick
data_bag: users
groups: sysadmin
id: mark
shell: /bin/bash

$ vi mark.json # add "action": "remove" again
$ knife data bag from file users mark.json -c knife.rb
Updated data_bag_item[users::mark]
$ knife search users 'groups:sysadmin OR NOT action:remove' -c knife.rb
0 items found


Reply to this email directly or view it on GitHubhttps://github.com//issues/22#issuecomment-20089863
.

from chef-zero.

jkeiser avatar jkeiser commented on July 27, 2024

Released in 1.5.2! Thanks tons! I need to figure out a way to track missing pedant tests so I can make those when I return.

from chef-zero.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.