fiksu/cluster_chef — comment on commit b65a7a5b74402c0c222ae9da27bd8163045997e8
File: site-cookbooks/cluster_service_discovery/libraries/cluster_service_discovery.rb line 60
By mrflip:

I see we're both working on the hadoop initial stability issue -- see

Passing the 'wait' flag down through all the `provider_private_ip` and so forth feels messy to me -- I'd rather add a helper that wraps the provider you're trying to call.... without a block raises on timeout, with a block it lets the chef run complete but skips those actions

```
# times out after 60 seconds
wait_for_provider_for_service(service_name, :timeout => 60) do
# ... stuff that happens once non-nil
end
# stuff that happens even if it can't find provider
```

My preference for that is weakly held however -- if you do go with options to the `provider_*` calls, I'd prefer giving it an options hash (separate out the main command's concern from the subcommands)

```
def provider_for_service service_name, options={}
options = { :wait => false, :timeout => 60, }.merge(options) # ?does chef provide reverse_merge?
wait = options[:wait]
# ... and so on
end
```

-------

You're also going to have issues when you stop-start machines, or otherwise need to reconverge -- this will happily sail through with no notion of the race condition. We should add a `knife cluster unprovide` that unregisters to provide all services, and have `knife cluster stop` invoke it along the way.