set_state not setting the state immediately

Konstantinos Tsakalozos kos.tsakalozos at
Tue Oct 3 12:34:28 UTC 2017


It seems the reactive framework is flushing the states at the end of hook
execution. This may surprise charm authors. Consider the following code:

def init():

def get_ready():

As a charm author I would expect the "initialized" state set right after
the must_be_called_exactly_once() is called. However, the framework is not
persisting the "initialized" state at that point, and it moves on to
trigger the get_ready(). Since this_call_fails() happens on
the  get_ready() method I would expect the "initialized" state to be set
when the failure is resolved.

The reason why the states are not set right away is that the entire hook is
tried after resolving the error. However, since hooks are hidden from the
charm author it is not clear when a hook starts and when it finishes. Also,
the set_state's behaviour of not immediately setting the state is

Konstantinos Tsakalozos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Juju mailing list