[chef] Re: Re: Iterating through parameters when a resource is retried


Chronological Thread 
  • From: Daniel DeLeo < >
  • To:
  • Subject: [chef] Re: Re: Iterating through parameters when a resource is retried
  • Date: Mon, 14 Jan 2013 10:19:02 -0800


On Monday, January 14, 2013 at 9:38 AM, Brian Hatfield wrote:

I wanted to bump this thread because I realized a more succinct way to ask my question:

Is there a way to cleanly handle the failure of a resource or a set of resources such that I can then perform some 'graceful degradation' action? (IE; 'begin...rescue' in regular ruby parlance, but that does not apply here)

Thank you!
Brian

Explicit support for this sort of thing was added as a one-off feature for remote_file resources[0] (but only merged for 11.0). I haven't looked at apt_repository's code in a while, but if it uses remote_file internally, there would probably be a small amount of integration work to get the mirror list feature wired up.

There isn't a general way of handling this, however. There is a retry parameter for all resources, but this isn't exactly what you're looking for. In the general case, you'd need to write a LWRP to wrap the underlying resource and iterate through your parameter list.


-- 
Daniel DeLeo

0. http://tickets.opscode.com/browse/CHEF-3375
 

On Fri, Jan 11, 2013 at 4:36 PM, Brian Hatfield < " target="_blank"> > wrote:
Given a resource like the following:

apt_repository "global-generic" do
    uri "SOMEURI"
    distribution "SOMEDISTRO"
    keyserver key_server
    key apt_key
    retries 2
end

it will retry if for example the keyserver is not reachable. For whatever reason, we are finding that large number of keyservers are not long-term reliable, or we are getting blocked, or something, but our keyserver requests time out.

What I would like to do is make keyserver be a list, and if the first item on the list fails, iterate to the second and so-on.

However, when I try this (ie, key_servers.pop), in practice it pops one item off the list and retries that item over and over rather than 'pop'ing a new item on each retry. I get that this is because of the way that convergence and such occurs, but is there any way for me to retry with different values?

Thank you!
Brian Hatfield





Archive powered by MHonArc 2.6.16.

§