Control different relation sequence

Gustavo Niemeyer gustavo.niemeyer at canonical.com
Wed Sep 4 02:33:51 UTC 2013


The relation-set command accepts a "-r" parameter which takes the relation id
to act upon. You can pick the relation id of an executing hook from
the JUJU_RELATION_ID environment variable. This way you can act across
relations.

Hopefully this will be better documented at some point.

On Tue, Sep 3, 2013 at 11:23 PM, Mike Sam <mikesam460 at gmail.com> wrote:
> Thanks Gustavo but I did not quite get your point. The problem is that for
> the new unit for service A, the dependent hooks are on two different
> independent relationships. I mean I can control when the new unit of Service
> A has properly established a relation with all the units of service B on say
> relation x_relation_changed, but how do I make all the units of service C to
> now trigger the y_relation_changed hook of the Service A unit because the
> unit is ready to process them? How do I make y_relation_changed hook to get
> triggered AGAIN (in case it has already been triggered but ignored because
> relation with service B was not done setting up) when x_relation_changed see
> fit? Would you please explain your point is the Service A, B, C context of
> my example?
>
>
>
>
> On Tue, Sep 3, 2013 at 6:38 PM, Gustavo Niemeyer
> <gustavo.niemeyer at canonical.com> wrote:
>>
>> Hi Mike,
>>
>> You cannot control the sequence in which the hooks are executed, but
>> you have full control of what you do when the hooks do execute. You
>> can choose to send nothing to the other side of the relation until its
>> time to report that a connection may now be established, and when you
>> do change the relation, the remote hook will run again to report the
>> change.
>>
>> On Tue, Sep 3, 2013 at 10:17 PM, Mike Sam <mikesam460 at gmail.com> wrote:
>> > Imagine a unit needs to be added to an existing service like service A.
>> > Service A is already in relations with other services like Service B and
>> > Service C on different "requires".
>> >
>> > For the new unit on Service A to work, it needs to first process the
>> > relation_joined and relation_changed with the units of service B before
>> > it
>> > could process  relation_joined and relation_changed with the units of
>> > service C.
>> >
>> > Is there a way to enforce such desired sequence relationship
>> > establishment
>> > at the charm level? In other words, I do not think we can control the
>> > hook
>> > execution sequence of different relationships officially but then I am
>> > wondering how can we do a situation like above nicely?
>> >
>> > Thanks,
>> > Mike
>> >
>> >
>> >
>> >
>> >
>> > --
>> > Juju-dev mailing list
>> > Juju-dev at lists.ubuntu.com
>> > Modify settings or unsubscribe at:
>> > https://lists.ubuntu.com/mailman/listinfo/juju-dev
>> >
>>
>> --
>> gustavo @ http://niemeyer.net
>
>



-- 
gustavo @ http://niemeyer.net



More information about the Juju mailing list