You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Potential solution: instead of emitting custom event, write something to unit peer databag (and ensure peer databag is updated [i.e. don't write data that's already there]) to trigger a peer-relation-changed event on all other units
In this case, I don't think we unfortunately can get away from emitting the event, in case the current unit is the elected leader unit - which will then not receive a peer-rel-changed event if the data is stored in its unit data bag..
I believe the fix is a mix of both approaches, something along the lines of:
if self.unit.is_leader():
self.on[PeerRelationName].relation_joined.emit(
self.model.get_relation(PeerRelationName)
)
self.peers_data.put(
Scope.UNIT, "updated_at", datetime.now().timestamp()
)
This block of code does not behave as the comment describes
opensearch-operator/lib/charms/opensearch/v0/opensearch_base_charm.py
Lines 471 to 476 in b0208dc
relation-joined
will only be emitted on that unit (whereopensearch-operator/lib/charms/opensearch/v0/opensearch_base_charm.py
Line 466 in b0208dc
And that unit will immediately return
opensearch-operator/lib/charms/opensearch/v0/opensearch_base_charm.py
Lines 294 to 297 in b0208dc
More info:
https://ops.readthedocs.io/en/latest/#ops.BoundEvent.emit
The text was updated successfully, but these errors were encountered: