Sequence of relation hooks?
clint at ubuntu.com
Mon Nov 14 17:46:34 UTC 2011
Excerpts from Joseph Heck's message of Sat Nov 12 10:50:54 -0800 2011:
> Is there a concise description of which hooks get called, and I'm which order, when two units are related to each other with "add-relation"?
> The "provides" and "requires" I can make guesses at, but I wasn't sure about the "peer" type of relation. Something as simple as a sequence diagram would be ideal - I'm just getting a little lost of what gets invoked where during the state change process.
Hi Joe, the most concise definition of how hooks are called is here:
There is no guaranteed ordering from relation to relation, so
provides/requires/etc. does not imply ordering, nor does peer. Your
hook script simply must act based on the fact that it is running, you
cannot assume other relations have run or will run after. I've found the
simplest thing to do is to save relation data somewhere accessible to all
hooks, and then check to see if there's enough information saved to go
ahead and fully configure/enable the service. You also can't assume that
changed implies that the other side has completely finished populating
all relation values you need. Thats why you will usually see changed
hooks doing something like
[ -n "$user" ] || exit 0
You *can* assume that joined will always happen at least once before
changed/departed, and that changed will happen at least once no matter
if a change has happened on the other side or not.
More information about the Juju