API change: relation-broken hook context

Kapil Thangavelu kapil.thangavelu at canonical.com
Thu Dec 8 23:09:37 UTC 2011


Excerpts from William Reade's message of Thu Dec 08 17:31:33 -0500 2011:
> It has become apparent that RelationHookContext is somewhat broken in
> the context of relation-broken: that is to say that commands like
> get-members are not guaranteed to work correctly, because state they
> depend upon may already have been deleted (by, say, the client
> requesting service destruction).
> 
> I propose that relation-broken should execute in a plain old HookContext
> (just like install/start/etc, but with JUJU_RELATION_NAME -- which is
> useful -- set in the environment).
> 
> Beneficial consequences:
> 
> * No opportunity for annoying bugs when state is missing
> * The code becomes a little better fitted to the problem, IMO
> 
> Unpleasant consequences:
> 
> * Some charms may need to change
> 
> Unintended consequences:
> 
> * ?
> 
> I admit that I haven't audited existing charms for use of unsafe
> commands, but I don't see that we have a practical way around the
> missing-state problem [0]. Given that, using RHC over HC for
> relation-broken just offers us a few extra commands of dubious utility
> and possible brokenness: and so if we can't guarantee they'll work, I
> feel we should just leave them out.
> 
> Thoughts?
> 
> Cheers
> William
> 
> [0] We could maybe do better if we had GC, but I'm not sure *any* of the
> commands exposed by RelationHookContext are really very meaningful when
> we're running relation-broken anyway.
> 

the rel hook even for rel-broken is distinct enough that i'd rather see an 
additional rel hook derived context for broken. Some uses, being able to know 
for example the name of the relation so it can reference associated resources, 
or look at what settings the unit had established for the relation so it can do 
proper cleanup.

regarding the additional api mapping of a rel hook context to a rel broken 
hook context.. i'd go with

get-members -> empty set
get relation settings of related unit -> error no such unit.
get relation settings of self unit -> works as normal
set setting relation setting of self -> error

cheers,

Kapil



More information about the Juju mailing list