Skip to content

Commit

Permalink
Wrong call
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomirp committed Dec 31, 2024
1 parent 5f3609f commit e55c8e6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1706,7 +1706,7 @@ def _set_primary_status_message(self) -> None:
danger_state = ""
if not self._patroni.has_raft_quorum():
danger_state = " (read-only)"
self.charm.unit_peer_data.update({"raft_stuck": "True"})
self.unit_peer_data.update({"raft_stuck": "True"})
elif len(self._patroni.get_running_cluster_members()) < self.app.planned_units():
danger_state = " (degraded)"
self.unit.status = ActiveStatus(
Expand Down
13 changes: 8 additions & 5 deletions tests/integration/ha_tests/test_scaling_three_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,26 @@ async def test_removing_unit(ops_test: OpsTest, roles: list[str], continuous_wri
await ops_test.model.destroy_unit(unit, force=True, destroy_storage=False, max_wait=1500)

if len(roles) > 1:
unit = ops_test.model.applications[DATABASE_APP_NAME].units[0]
for left_unit in ops_test.model.applications[DATABASE_APP_NAME].units:
if left_unit.name not in units:
break

await ops_test.model.block_until(
lambda: unit.workload_status_message == "Primary (read-only)"
or unit.workload_status_message == "Raft majority loss, run: promote-to-primary",
lambda: left_unit.workload_status_message == "Primary (read-only)"
or left_unit.workload_status_message == "Raft majority loss, run: promote-to-primary",
timeout=600,
)

run_action = (
await ops_test.model.applications[DATABASE_APP_NAME]
.units[0]
.run_action("promote-to-primary", scope="unit", force="True")
.run_action("promote-to-primary", scope="unit", force=True)
)
await run_action.wait()

await ops_test.model.wait_for_idle(status="active", timeout=600)

await are_writes_increasing(ops_test, unit)
await are_writes_increasing(ops_test, units)

logger.info("Scaling back up")
await ops_test.model.applications[DATABASE_APP_NAME].add_unit(count=len(roles))
Expand Down

0 comments on commit e55c8e6

Please sign in to comment.