Hi,

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

@when_not("initialized")
def init():
    must_be_called_exactly_once()
    set_state("initialized")

@when("initialized")
@when_not("ready")
def get_ready():
    this_call_fails()
    set_state("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
counter-intuitive.

Thanks,
Konstantinos Tsakalozos
-- 
Juju mailing list
Juju@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju

Reply via email to