$REMOTE_UNIT not found in relation-list during -joined hook

Bug #1458754 reported by Stuart Bishop
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
juju-core
New
Undecided
Unassigned

Bug Description

When running a relation-joined hook, I have a $REMOTE_UNIT and I can retrieve the other units data using relation-get. However, the remote unit is not listed in relation-list.

This causes odd behavior in relation-joined hooks. For example:

hookenv.relation_set(mydata=foo)
aggregate = [hookenv.relation_get(mydata, unit=u) for u in hookenv.related_units]
hookenv.relation_set(aggregate=' '.join(aggregate)

This snippet of code will set incomplete data in the relation-joined hook, but the complete set of data in the relation-changed hook.

For a real example, my master-relation-joined hook was adding $REMOTE_UNIT to the list of authorized units. However, the code that actually generates the authorization file is called by several hooks and thus needs to iterate over the relation information and was unable to discover the new unit. The -joined hook ended up informing the client it was authorized when it was not, but it worked from the changed hook. The client would randomly fail to connect depending on the order of the client and servers hooks being called.

Curtis Hovey (sinzui)
tags: added: hooks relations
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.