Skip to content

Commit e0f134a

Browse files
[MISC] Fix Juju Spaces lack of addresses (II) (#657)
1 parent 58b5011 commit e0f134a

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/charm.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,18 @@ def update_endpoint_addresses(self) -> None:
722722
f"{RELATION_CONSUMER}-address": self.replication_consumer_address,
723723
})
724724

725+
def update_endpoint_address(self, relation_name: str) -> None:
726+
"""Update ip address for the provided relation on unit peer databag."""
727+
logger.debug(f"Updating {relation_name} endpoint address")
728+
729+
relation_binding = self.model.get_binding(relation_name)
730+
if not relation_binding:
731+
return
732+
733+
self.unit_peer_data.update({
734+
f"{relation_name}-address": str(relation_binding.network.bind_address)
735+
})
736+
725737
def install_workload(self) -> bool:
726738
"""Exponential backoff retry to install and configure MySQL.
727739

src/relations/mysql_provider.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def _update_endpoints(self, relation_id: int, remote_app: str) -> None:
157157
relation_id (int): The id of the relation
158158
remote_app (str): The name of the remote application
159159
"""
160-
self.charm.update_endpoint_addresses()
160+
self.charm.update_endpoint_address(DB_RELATION_NAME)
161161

162162
try:
163163
rw_endpoints, ro_endpoints, _ = self.charm.get_cluster_endpoints(DB_RELATION_NAME)
@@ -230,6 +230,9 @@ def _on_database_requested(self, event: DatabaseRequestedEvent):
230230

231231
remote_app = event.app.name
232232

233+
# Update endpoint addresses
234+
self.charm.update_endpoint_address(DB_RELATION_NAME)
235+
233236
try:
234237
db_version = self.charm._mysql.get_mysql_version()
235238
rw_endpoints, ro_endpoints, _ = self.charm.get_cluster_endpoints(DB_RELATION_NAME)

0 commit comments

Comments
 (0)