Search problem

I have a strange problem with duplicate attributes appearing on a node
returned from a search when that is the node currently being processed.

The setup is that I have an attribute which is an array of hashes and
the basic details are defined in a role which gives the attribute a
value which is an array of two hashes.

There is then a recipe which adds extra details to the two hashes which
are computed from the entries defined by the role so by the time the
chef run finishes and the attributes are submitted back to the server
the hashes are fully populated.

Now if I do a search in a recipe and get a set of nodes back then I find
that for most nodes in the result I have the fully populated hashes that
I expect, but if the search result includes the node currently being
processed the instead of two entries in the array there are four - two
fully populated ones (presumably from the last run) and two partially
populated ones which only have the values set by the role.

This is true even if the recipe that fills in the extra values has
already been run.

I’ve looked at the chef source and as far as I can see all the data on a
node returned by a search has come from the server, so I don’t
understand why I am seeing the partially populated hashes as I thought
the new attributes weren’t sent to the server until the end of the run?

Any ideas what is going on, or how I can avoid getting these duplicates?

Thanks,

Tom


Tom Hughes (tom@compton.nu)
http://compton.nu/

Hi Tom,

On Mon, Jun 20, 2011 at 1:11 PM, Tom Hughes tom@compton.nu wrote:

I have a strange problem with duplicate attributes appearing on a node
returned from a search when that is the node currently being processed.

The setup is that I have an attribute which is an array of hashes and the
basic details are defined in a role which gives the attribute a value which
is an array of two hashes.

There is then a recipe which adds extra details to the two hashes which are
computed from the entries defined by the role so by the time the chef run
finishes and the attributes are submitted back to the server the hashes are
fully populated.

Now if I do a search in a recipe and get a set of nodes back then I find
that for most nodes in the result I have the fully populated hashes that I
expect, but if the search result includes the node currently being processed
the instead of two entries in the array there are four - two fully populated
ones (presumably from the last run) and two partially populated ones which
only have the values set by the role.

This is true even if the recipe that fills in the extra values has already
been run.

I've looked at the chef source and as far as I can see all the data on a
node returned by a search has come from the server, so I don't understand
why I am seeing the partially populated hashes as I thought the new
attributes weren't sent to the server until the end of the run?

Any ideas what is going on, or how I can avoid getting these
duplicates?

What versions of Chef Server and chef-client are in play here? Prior
to Chef 0.10, the chef-client saved nodes at the beginning of a run.
The indexing is not instant, but it is possible that a search could
pick up this intermediate state.

  • seth

--
Seth Falcon | Senior Software Design Engineer | Opscode | @sfalcon