Skip to content

Commit 0b46746

Browse files
Fix issue if incompatible upgrade forced (#131)
Ported from canonical/mysql-router-k8s-operator#231
1 parent f82a3d2 commit 0b46746

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/abstract_charm.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ def reconcile(self, event=None) -> None: # noqa: C901
233233
logger.debug("Peer relation not ready")
234234
return
235235
workload_ = self.get_workload(event=event)
236+
if self._unit_lifecycle.authorized_leader and not self._upgrade.in_progress:
237+
# Run before checking `self._upgrade.is_compatible` in case incompatible upgrade was
238+
# forced & completed on all units.
239+
self._upgrade.set_versions_in_app_databag()
236240
if self._upgrade.unit_state == "restarting": # Kubernetes only
237241
if not self._upgrade.is_compatible:
238242
logger.info(
@@ -300,8 +304,6 @@ def reconcile(self, event=None) -> None: # noqa: C901
300304
self._upgrade.unit_state = "healthy"
301305
if self._unit_lifecycle.authorized_leader:
302306
self._upgrade.reconcile_partition()
303-
if not self._upgrade.in_progress:
304-
self._upgrade.set_versions_in_app_databag()
305307
self.set_status(event=event)
306308
except server_exceptions.Error as e:
307309
# If not for `unit=False`, another `server_exceptions.Error` could be thrown here

0 commit comments

Comments
 (0)