Skip to content

Commit

Permalink
advertise ip address of each unit, not just the current master (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
reneradoi authored Jun 19, 2024
1 parent 08f27f9 commit b506926
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ def _redis_pebble_ready(self, event) -> None:
# In the event of a pod restart on the same node the upgrade event is not fired.
# The IP might change, so the data needs to be propagated
for relation in self.model.relations[REDIS_REL_NAME]:
relation.data[self.model.unit]["hostname"] = socket.gethostbyname(self.current_master)
relation.data[self.model.unit]["hostname"] = socket.gethostbyname(
self.unit_pod_hostname
)

def _upgrade_charm(self, event: UpgradeCharmEvent) -> None:
"""Handle the upgrade_charm event.
Expand Down Expand Up @@ -248,7 +250,7 @@ def _peer_relation_changed(self, event):
if relations:
for relation in relations:
relation.data[self.model.unit]["hostname"] = socket.gethostbyname(
self.current_master
self.unit_pod_hostname
)
if self._peers.data[self.unit].get("upgrading", "false") == "true":
self._peers.data[self.unit]["upgrading"] = ""
Expand Down

0 comments on commit b506926

Please sign in to comment.