Hook -relation-broken is broken with charms.reactive

Cory Johns cory.johns at canonical.com
Sat Dec 19 19:13:08 UTC 2015


On Sat, Dec 19, 2015 at 3:45 AM, Stuart Bishop <stuart.bishop at canonical.com>
wrote:

> Which unit name would you use? -relation-departed gets run multiple
> times, once for each unit. -relation-broken gets run once, after all
> the -departed hooks have been run.


That can't be right.  Surely it must run at least once on each unit still
remaining in the relation.  Every relation consists of two end-points, and
even if the implementation of Juju means that it's difficult or impossible
for the agent to populate that variable, there's still an objectively
correct value to put there.  And it doesn't seem unreasonable to have
expected Juju to do so, like it does for every relation hook.

Also, as I referenced previously, I'm pretty sure that I could reconstruct
the expected value by saving the list of departing unit(s) in the charm and
comparing that to the list during the -broken hook.  But my point was that
I'm not sure it's worth doing that because I'm not sure I see a use-case
for this hook that couldn't just as easily be done with the -departed hook
alone.


> Oh, and as the relation is *gone* by this point, self.set_remote and
> get_remote will fail.
>

I'm fully aware of that and never intended to use get/set_remote during
-broken.  However, it does make sense to remove reactive states during
-broken to ensure that they aren't incorrectly applied to relations that no
longer exist.  However, this could also reasonably be done in -departed.


> As far as the reactive framework is concerned, I don't think it fits
> as a handler on a RelationBase subclass. It would work fine as a
> 'standard' parameterless handler. Maybe you want some magic to destroy
> conversations and such from the now defunct and useless relation
> object.
>

I'm not sure I understand what you mean here.  I don't see the need for any
"magic" here.  During a relation hook, charms.reactive needs to be able to
determine what two units the relation applied to in order to know what
conversations they may have been participating in and those conversations'
associated states.  If it can't determine that for -broken, then -broken
can't be used with charms.reactive.

But, again, my question is whether it is even useful to do anything with
-broken in reactive charms?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/juju/attachments/20151219/c4abf69b/attachment.html>


More information about the Juju mailing list