start/stop hook guarantees

William Reade william.reade at
Fri Dec 2 17:23:29 UTC 2011

Following up on a team discussion in G+ yesterday:

We agreed that we should always call the start hook whenever the machine
restarts, regardless of the current state. This feels similar enough to
an API change that we should probably get it discussed/recorded here.

So, consider this fair warning and/or opportunity to complain:

If the machine running your charm is restarted, we guarantee that the
charm's start hook will be called once as soon as its unit agent first
comes up. However, if it's just the unit agent being restarted, your
service will not be notified at all.

Note that we can't guarantee that the stop hook will be called on
shutdown, but it will be if the unit agent is shut down cleanly (which
it should be, in the case of a controlled shutdown or restart); ie, we
can't make any guarantees about the state of the service at the time the
start hook is called.

In my personal opinion, this should affect a properly-written charm not
one jot; this is because juju doesn't track what your service is
*actually* doing, and is not capable of detecting that it has fallen
over, and so -- if you want your charm to be robust -- you'll want to be
running it under upstart (or similar) anyway, and will therefore likely
already be coming up automatically on boot; and you will of course have
made all your hooks properly idempotent.

If you're writing a slightly lazier charm [0], though, this should be
helpful behaviour.

Does anyone have any comments or objections before I go ahead and
implement this?


[0] Or, I suppose, one for a freakishly robust service :-p.

More information about the Juju mailing list