Skip to content

Commit

Permalink
Repatch service
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomirp committed Jul 16, 2024
1 parent fc9e6f2 commit ea40121
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/relations/backend_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,11 @@ def _on_relation_departed(self, event: RelationDepartedEvent):

if event.departing_unit == self.charm.unit:
# This should only occur when the relation is being removed, not on scale-down
self.charm.peers.unit_databag.update({
f"{BACKEND_RELATION_NAME}_{event.relation.id}_departing": "true"
})
logger.warning("added relation-departing flag to peer databag")
if self.charm.peers.unit_databag:
self.charm.peers.unit_databag.update({
f"{BACKEND_RELATION_NAME}_{event.relation.id}_departing": "true"
})
logger.warning("added relation-departing flag to peer databag")
return

if not self.charm.unit.is_leader() or event.departing_unit.app != self.charm.app:
Expand Down
7 changes: 7 additions & 0 deletions src/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
from pydantic import BaseModel
from typing_extensions import override

from constants import CLIENT_RELATION_NAME

DEFAULT_MESSAGE = "Pre-upgrade check failed and cannot safely upgrade"

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -89,6 +91,11 @@ def _on_pgbouncer_pebble_ready(self, event: WorkloadEvent) -> None:
if self.peer_relation.data[self.charm.unit].get("state") != "upgrading":
return

if self.charm.unit.is_leader():
self.charm.patch_port(self.charm.client_relation.external_connectivity())
for relation in self.model.relations.get(CLIENT_RELATION_NAME, []):
self.client_relation.update_connection_info(relation)

try:
self._cluster_checks()
except ClusterNotReadyError:
Expand Down

0 comments on commit ea40121

Please sign in to comment.