relation-get - missing_unit behavior

Gustavo Niemeyer gustavo at niemeyer.net
Mon Jun 24 13:24:13 UTC 2013


On Mon, Jun 24, 2013 at 4:50 AM, Stuart Bishop
<stuart.bishop at canonical.com> wrote:
> On Sat, Jun 22, 2013 at 12:48 PM, Mark Shuttleworth <mark at ubuntu.com> wrote:
>> On 06/21/2013 10:26 PM, Gustavo Niemeyer wrote:
>>> Fetching relation data for non-existing units does sound pathological
>>> and twisted. It means that the charm is basically implying it knows
>>> how the context it's being deployed under looks like, including remote
>>> units it can talk to.
>>
>> The rationale is to have charms which are useful in many places. A charm
>> which makes assumptions about what's around it is by definition only
>> useful when those assumptions are true. So, it would be worth taking the
>> time to make it useful with, or without, the relations that may or may
>> not show up.
>
> In this case the charm does know what the context its being deployed
> under looks like,  and the charm isn't making an assumption. It knows
> the unit will join the relation eventually (unless it gets removed
> before it has a chance to)

Right, it knows unless it doesn't. :-)

> because of the existing peer relationship.
> In this particular case, Juju could know it too. But even if this was
> not the case, who would know better than the charm what the context
> it's being deployed under looks like?

juju itself. It has knowledge of all the services, all of the units,
all of the configuration, and all of the relationships, established or
not.

(...)
> I do think it is an edge case. I don't know if gaining consistency
> here is worth making bugs harder to find when bogus values are passed
> to relation-get.

Right, that's part of the issue. The other part is making it easier to
have good designs. In general people shouldn't be building charms with
the assumption that they know of established relationships that in
fact aren't established. Perhaps your design is not a problem, because
you're passing the unit name via a peer relation, but think about the
big picture of people preemptively hardcoding service names inside a
charm. I've seen people attempting that, and it's a good thing that
it's breaking in those cases.


gustavo @ http://niemeyer.net



More information about the Juju mailing list