At some point several months back, I had a discussion with some folks.
Maybe it was at ChefConf. Regardless, we discussed the idea of a
"cached search". Opscoded added (or maybe it hasn’t made it in yet),
the idea of partial search. My suggestion/idea was that the idea of a
cached search be added that was computed once at the beginning of the
run and saved globally for the whole run. The thought was that we
frequently perform the exact same search across different recipes. For
instance in ours we have this at the top of almost every recipe:
distributor = search(:node, “role:distributor AND
That’s how we locate our current internal blob distribution point
(nginx serving a bunch of files for Chef in this case).
It would be pretty awesome if we only had to compute that once. I’ve
not tinkered with any specific implementation yet. Does the idea
interest anyone else? I was thinking either an additional parameter to
the existing search (’:cached => true’) or possibly a new LWRP (in the
same way I did encrypted databags before official support was there).
I’ve never looked at the guts of search but I’m pretty sure there are
some possible edge cases where search results would change mid-run
between recipes that could cause some nasty issue to crop up.
John E. Vincent