Skip to content

Commit 5e54c4a

Browse files
[DPE-10454] Use better status instead of blocked for transient update failures (#1861)
Use maintenance status instead of blocked one. The 'failed to update cluster members on member' BlockedStatus was misleading: these are transient, self-recovering conditions (a RetryError from update_config(), or a peer IP not yet published) rather than states needing operator intervention. Replace them with MaintenanceStatus and a 'updating cluster members' message. Update test_on_peer_relation_changed accordingly, and set an explicit BlockedStatus before exercising the early-exit guard so that path stays covered. (cherry picked from commit eddf95e) Assisted-by: Claude:claude-5-fable
1 parent f9cb3d6 commit 5e54c4a

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/charm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ def _on_peer_relation_changed(self, event: HookEvent):
749749
# Update the members of the cluster in the Patroni configuration on this unit.
750750
self.update_config()
751751
except RetryError:
752-
self.unit.status = BlockedStatus("failed to update cluster members on member")
752+
self.unit.status = MaintenanceStatus("cluster member update failed, retrying")
753753
return
754754
except ValueError as e:
755755
self.unit.status = BlockedStatus("Configuration Error. Please check the logs")
@@ -955,7 +955,7 @@ def add_cluster_member(self, member: str) -> None:
955955
try:
956956
self.update_config()
957957
except RetryError:
958-
self.unit.status = BlockedStatus("failed to update cluster members on member")
958+
self.unit.status = MaintenanceStatus("cluster member update failed, retrying")
959959

960960
def _get_unit_ip(self, unit: Unit) -> str | None:
961961
"""Get the IP address of a specific unit."""

tests/unit/test_charm.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,11 +1445,12 @@ def test_on_peer_relation_changed(harness):
14451445
_update_config.assert_called_once()
14461446
_start_patroni.assert_not_called()
14471447
_update_new_unit_status.assert_not_called()
1448-
assert isinstance(harness.model.unit.status, BlockedStatus)
1448+
assert isinstance(harness.model.unit.status, MaintenanceStatus)
14491449

14501450
# Test event is early exiting when in blocked status.
14511451
_update_config.side_effect = None
14521452
_member_started.return_value = False
1453+
harness.model.unit.status = BlockedStatus()
14531454
harness.charm._on_peer_relation_changed(mock_event)
14541455
_start_patroni.assert_not_called()
14551456

@@ -1791,12 +1792,11 @@ def test_add_cluster_member(harness):
17911792
_update_config.assert_called_once_with()
17921793
_update_config.reset_mock()
17931794

1794-
# Charm blocks when update_config fails
1795+
# Charm goes into maintenance when update_config fails
17951796
_update_config.side_effect = RetryError(last_attempt=None)
17961797
harness.charm.add_cluster_member("postgresql/0")
17971798
_update_config.assert_called_once_with()
1798-
assert isinstance(harness.charm.unit.status, BlockedStatus)
1799-
assert harness.charm.unit.status.message == "failed to update cluster members on member"
1799+
assert isinstance(harness.charm.unit.status, MaintenanceStatus)
18001800
_update_config.reset_mock()
18011801

18021802
# Not ready error if not all members are ready

0 commit comments

Comments
 (0)