Skip to content

Commit b6fc686

Browse files
fix: don't remove from quorum if application is going down (#149)
1 parent 444f3d5 commit b6fc686

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
cffi==1.16.0 ; python_version >= "3.10" and python_version < "4.0" and platform_python_implementation != "PyPy"
22
cosl==0.0.11 ; python_version >= "3.10" and python_version < "4.0"
3-
cryptography==42.0.5 ; python_version >= "3.10" and python_version < "4.0"
3+
cryptography==42.0.7 ; python_version >= "3.10" and python_version < "4.0"
44
kazoo==2.9.0 ; python_version >= "3.10" and python_version < "4.0"
55
ops==2.13.0 ; python_version >= "3.10" and python_version < "4.0"
66
pure-sasl==0.6.2 ; python_version >= "3.10" and python_version < "4.0"
77
pycparser==2.22 ; python_version >= "3.10" and python_version < "4.0" and platform_python_implementation != "PyPy"
88
pydantic==1.10.15 ; python_version >= "3.10" and python_version < "4.0"
99
pyyaml==6.0.1 ; python_version >= "3.10" and python_version < "4.0"
1010
six==1.16.0 ; python_version >= "3.10" and python_version < "4.0"
11-
tenacity==8.2.3 ; python_version >= "3.10" and python_version < "4.0"
12-
typing-extensions==4.11.0 ; python_version >= "3.10" and python_version < "4.0"
11+
tenacity==8.3.0 ; python_version >= "3.10" and python_version < "4.0"
12+
typing-extensions==4.12.0 ; python_version >= "3.10" and python_version < "4.0"
1313
websocket-client==1.8.0 ; python_version >= "3.10" and python_version < "4.0"

src/charm.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from charms.grafana_agent.v0.cos_agent import COSAgentProvider
1111
from charms.rolling_ops.v0.rollingops import RollingOpsManager
1212
from charms.zookeeper.v0.client import QuorumLeaderNotFoundError
13-
from kazoo.exceptions import BadVersionError, ReconfigInProcessError
13+
from kazoo.exceptions import BadArgumentsError, BadVersionError, ReconfigInProcessError
1414
from ops import (
1515
ActiveStatus,
1616
CharmBase,
@@ -225,7 +225,7 @@ def _on_cluster_relation_departed(self, event: RelationDepartedEvent) -> None:
225225
# likely due to a controller upgrade or a cloud maintenance with machines being reshuffled
226226
# periodically, juju would emit a LeaderElected event, and would return no peer units
227227
# the leader would then remove all other units from the quorum, which when restarted, would fail
228-
if not event.departing_unit:
228+
if not event.departing_unit or not self.model.app.planned_units():
229229
return
230230

231231
departing_server_id = (
@@ -238,6 +238,7 @@ def _on_cluster_relation_departed(self, event: RelationDepartedEvent) -> None:
238238
ReconfigInProcessError, # another unit already handling
239239
BadVersionError, # another unit handled
240240
QuorumLeaderNotFoundError, # this unit is departing, can't find leader in peer data
241+
BadArgumentsError, # already handled
241242
):
242243
pass
243244

tests/integration/test_tls.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ async def test_deploy_ssl_quorum(ops_test: OpsTest):
2626
channel="edge",
2727
num_units=1,
2828
config={"ca-common-name": "zookeeper"},
29+
revision=163,
2930
),
3031
)
3132
await ops_test.model.add_relation(APP_NAME, TLS_NAME)
@@ -70,6 +71,7 @@ async def test_add_tls_provider_succeeds_after_removal(ops_test: OpsTest):
7071
channel="edge",
7172
num_units=1,
7273
config={"ca-common-name": "zookeeper"},
74+
revision=163,
7375
),
7476
)
7577

0 commit comments

Comments
 (0)