[chef] Weird search behavior, need advice


Chronological Thread 
  • From: "Jordan Wesolowski" < >
  • To:
  • Subject: [chef] Weird search behavior, need advice
  • Date: Mon, 18 May 2015 12:15:13 -0700 (PDT)

Hello Chef Community,

I’ve noticed an interesting problem with searching that has to do with the behavior of SOLR. Normally, when looking for nodes that are in the same Chef environment, we would do something like this:

search(:node, “chef_environment:#{node.chef_environment}”)

Unfortunately, SOLR will pick up a node in a different environment if it has a nested attribute with the same name. So for example, a node has:

node.set[‘break’][‘search’][‘with’][‘chef_environment’] = ‘production'

That node would show up in search results looking for production nodes regardless of its actual chef environment.

I whipped together a quick example with tests here:
https://github.com/jrwesolo/chef_search_woes

A fix will cause all the tests to pass. I have an example fix in a comment of the default recipe, but I was hoping for a solution that was a little more elegant.

Does anyone have any advice on a better way to do this? I use chef_environment and ipaddress as examples in the cookbook, but it could be any other attribute that happens to conflict due to nesting.

Sincerely,
Jordan Wesolowski





Archive powered by MHonArc 2.6.16.

§