Hi
I use search quite heavily in my Chef recipes, mainly to return a list
of nodes based on a provided environment and role. I then assign
attributes to the results of these searches, which are then references
in configuration files on other nodes. An example might be, a web host
might need to know which app hosts it can pass work off to, and the app
hosts might be an occasionally shifting number. So, great, dynamic
assignment of values in the config based on search.
However, I have hit two areas where the search really isn’t working for
us as intended/expected. And I don’t know if this is my fauly
expectations, my faulty implementation , or something wrong in Chef.
-
Scenario 1 - Nodes vanish from search when I update chef via knife.
I make updates to files in the git repo and then import them to chef
couch/solr using:
“knife cookbook upload”, “knife environment from file”, "knife node
from file, "knife role from file"
It appears as though running at least some of these commands
re-creates the nodes as new objects with no roles (rather than updates
the existing objects) so that the nodes have no roles until the
chef-client is successfully run on the client host. -
Scenario 2 - Nodes vanish from search results intermittently.
It appears as though intermittently search will not return a node in
the search results for a role that I know it has. I can manually
re-populate the roles by running the chef-client executable on the host
in question.
Both these together mean that at times, a node will not be returned as
the result of a search, meaning the config value used elsewhere is null,
which can cause massive problems for our environments.
Can someone advise if I am doing something wrong in my use of search,
if the above can be explained by any known bugs, or how I can resolve
these issues please. I am unclear on what determines whether a host has
a role - in my mind it should be whether a host has a role assigned in
the config, but sometimes nodes are not returned in the search when they
are assigned in the config, and appear in search only after a
successul client run is performed manually.
Cheers
Dan