Problem
Every unit of the application needs to be aware of what peers are available following the joining or departing of a peer unit.
Attempted Solution
In an attempt to have all units in sync with the data on the relation for existing peers, I am updating the stored state of each unit any time data changes on the relation using the relation-changed hook event for the peer relation. The problem I am experiencing is that I have not been able to get the relation-changed hook to fire across the remaining units when a unit departs the relation. This leads me to believe that the departing unit’s data remains in the relation data after the unit leaves the relation.
Using this code to test with, in combination with running some debugging commands in the terminal and juju debug logs, we were able to verify that a unit’s data is not removed from the relation data when a unit departs from the relation.
From the terminal output above, you can see
$ juju remove-unit peerer/23
removing unit peerer/23
$ juju run --unit peerer/24 "relation-get --relation=10 hostname peerer/23"
juju-41e4a5-23
To me, this shows that the relation data for peerer/23 is still in the relation.
Possible someone could verify my findings here? I think I have a pretty strong case, but would like some outside perspective.
Thanks!