Sequence of relation hooks?

Gustavo Niemeyer gustavo.niemeyer at
Mon Nov 14 18:26:19 UTC 2011

(... good info ...)
> 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.

Nice description, thanks Clint.

There's two more useful guarantees worth mentioning: all relation
changes performed within a hook will be observed simultaneously, and
the relation data for a given unit will not change while a hook is

In other words, if you do this within a hook:

    relation-set user=myuser
    relation-set pass=mypass

These two values are guaranteed to be seen together.

Conversely, if you do this:

    USER=`relation-get user`
    PASS=`relation-get pass`

The two values are guaranteed to be related (assuming they were set in
the same hook execution as per above).

This is the kind of software magic that is good: the semantics
disappear because they're obviously what one would expect.

Gustavo Niemeyer

-- I'm not absolutely sure of anything.

More information about the Juju mailing list