Hook -relation-broken is broken with charms.reactive
Stuart Bishop
stuart.bishop at canonical.com
Sat Dec 19 08:45:33 UTC 2015
On 19 December 2015 at 04:49, Cory Johns <cory.johns at canonical.com> wrote:
> I recently stumbled across https://bugs.launchpad.net/juju-core/+bug/1098442
> by way of realizing that the @hook('{relation_name}-relation-broken')
> handlers in my interface layer were not doing anything. At all.
>
> It turns out that without knowing for what remote unit the -relation-broken
> hook is running, charms.reactive cannot get, set, or remove any states for
> any conversations in which that unit had participated. This renders the
> -relation-broken hook completely unusable in reactive charms.
>
> However, the -relation-departed hook works perfectly fine.
>
> I think I have a way that I could reconstruct the appropriate remote unit
> name in charms.reactive to make the -relation-broken hook work as expected,
> but given the fact that -relation-departed works just as well, I'm not sure
> if there is enough of a use-case for the -broken hook to warrant it.
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. Oh, and as the relation is *gone*
by this point, self.set_remote and get_remote will fail.
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.
> So I wanted to put it to the community. Is there something that
> -relation-broken would let you do that -relation-departed could not
> accomplish just as easily? Is there any reason to try to make it work, or
> should we just deprecate -relation-broken for reactive charms, possibly even
> making it an error to try to react to it?
--
Stuart Bishop <stuart.bishop at canonical.com>
More information about the Juju
mailing list