Skip to content

Commit

Permalink
won't defer single unit restart (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulomach committed Jun 20, 2024
1 parent 794fbb5 commit 2b48058
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,13 @@ def _reconcile_pebble_layer(self, container: Container) -> None:

def _restart(self, event: EventBase) -> None:
"""Restart the service."""
if self._mysql.is_unit_primary(self.unit_label):
if self.peers.units != self.restart_peers.units:
# defer restart until all units are in the relation
logger.debug("Deferring restart until all units are in the relation")
event.defer()
return
if self.peers.units and self._mysql.is_unit_primary(self.unit_label):
# delay primary on multi units
restart_states = {
self.restart_peers.data[unit].get("state", "unset") for unit in self.peers.units
}
Expand Down

0 comments on commit 2b48058

Please sign in to comment.