chef / chef-zero

Simple, easy-run, fast-start in-memory Chef server for testing and solo purposes
Apache License 2.0
532 stars 98 forks source link

Incorrect search behavior when a query parameter contains a '-' character #31

Closed wilreichert closed 11 years ago

wilreichert commented 11 years ago

We're using vagrant + chef-zero for dev & noticed an odd search behavior. There are 2 nodes running concurrently with different sets of recipes:

Node Name:   control
Environment: dev
FQDN:        control
IP:          10.0.2.15
Run List:    recipe[ktc-base], role[os-compute-single-controller]
Roles:       os-compute-single-controller, os-base, os-ops-database, os-identity, os-image, os-image-registry, os-image-api, os-compute-scheduler, os-compute-api, os-compute-api-ec2, os-compute-api-os-compute, os-compute-api-metadata, os-block-storage, os-compute-cert, os-compute-vncproxy, os-dashboard, infra-caching
Recipes:     ktc-base, openstack-common, openstack-common::logging, openstack-ops-database::server, ktc-messaging, openstack-ops-database::openstack-db, openstack-identity::server, openstack-identity::registration, openstack-image::registry, openstack-image::api, ktc-network, openstack-compute::scheduler, openstack-compute::api-ec2, openstack-compute::api-os-compute, openstack-compute::api-metadata, openstack-block-storage, openstack-compute::nova-cert, openstack-compute::vncproxy, openstack-dashboard::server, openstack-object-storage::memcached
Platform:    ubuntu 12.04
Tags:

Node Name:   worker1
Environment: dev
FQDN:        worker1
IP:          10.0.2.15
Run List:    recipe[ktc-base], recipe[ktc-compute]
Roles:
Recipes:     ktc-base, ktc-compute
Platform:    ubuntu 12.04
Tags:

The worker1 node contains ktc-compute the control node does not. Our code does a search for this recipe.

The following is shef output on the worker1 node ( both nodes produce the same output )

chef > resp = search("node", "recipes:ktc-compute")
 => [node[control], node[worker1]]
chef > resp = search(:node, "recipes:ktc-computeaaa")
 => [node[control], node[worker1]]
chef > resp = search("node", "run_list:ktc-aaa")
 => [node[control], node[worker1]]
chef > resp = search("node", "run_list:k")
 => []
chef > resp = search("node", "run_list:kt")
 => []
chef > resp = search("node", "run_list:ktc")
 => [node[control], node[worker1]]
chef > resp = search("node", "recipes:ktc-")
[2013-08-02T15:25:24+09:00] ERROR: Server returned error for http://192.168.31.86:4000/search/node?q=recipes:ktc-&sort=X_CHEF_id_CHEF_X%20asc&start=0&rows=1000, retrying 1/5 in 3s
^[[A^[[A[2013-08-02T15:25:27+09:00] ERROR: Server returned error for http://192.168.31.86:4000/search/node?q=recipes:ktc-&sort=X_CHEF_id_CHEF_X%20asc&start=0&rows=1000, retrying 2/5 in 5s
^CIRB::Abort: abort then interrupt!
(stack trace removed)
chef > resp = search("node", "run_list:ktc\-compute")
 => [node[control], node[worker1]]
chef > resp = search("node", "recipes:ktc\\-compute")
 => [node[worker1]]

It appears the - is being interpreted as a wildcard of sorts and the search does not work correctly unless it is escaped.

This was tested on a real chef server & works as expected: search("node", "recipes:ktc-compute") returns the worker1 node, the others return nothing or an error.

jkeiser commented 11 years ago

It looks a lot like we're not breaking recipe[ktc-compute] up the way solr expects. Probably - needs to remain part of a word. I'll take a look, thanks!