Skip to content

Commit

Permalink
fix: don't remove from quorum if application is going down (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoppenheimer authored Aug 18, 2024
1 parent 444f3d5 commit b6fc686
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
cffi==1.16.0 ; python_version >= "3.10" and python_version < "4.0" and platform_python_implementation != "PyPy"
cosl==0.0.11 ; python_version >= "3.10" and python_version < "4.0"
cryptography==42.0.5 ; python_version >= "3.10" and python_version < "4.0"
cryptography==42.0.7 ; python_version >= "3.10" and python_version < "4.0"
kazoo==2.9.0 ; python_version >= "3.10" and python_version < "4.0"
ops==2.13.0 ; python_version >= "3.10" and python_version < "4.0"
pure-sasl==0.6.2 ; python_version >= "3.10" and python_version < "4.0"
pycparser==2.22 ; python_version >= "3.10" and python_version < "4.0" and platform_python_implementation != "PyPy"
pydantic==1.10.15 ; python_version >= "3.10" and python_version < "4.0"
pyyaml==6.0.1 ; python_version >= "3.10" and python_version < "4.0"
six==1.16.0 ; python_version >= "3.10" and python_version < "4.0"
tenacity==8.2.3 ; python_version >= "3.10" and python_version < "4.0"
typing-extensions==4.11.0 ; python_version >= "3.10" and python_version < "4.0"
tenacity==8.3.0 ; python_version >= "3.10" and python_version < "4.0"
typing-extensions==4.12.0 ; python_version >= "3.10" and python_version < "4.0"
websocket-client==1.8.0 ; python_version >= "3.10" and python_version < "4.0"
5 changes: 3 additions & 2 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from charms.grafana_agent.v0.cos_agent import COSAgentProvider
from charms.rolling_ops.v0.rollingops import RollingOpsManager
from charms.zookeeper.v0.client import QuorumLeaderNotFoundError
from kazoo.exceptions import BadVersionError, ReconfigInProcessError
from kazoo.exceptions import BadArgumentsError, BadVersionError, ReconfigInProcessError
from ops import (
ActiveStatus,
CharmBase,
Expand Down Expand Up @@ -225,7 +225,7 @@ def _on_cluster_relation_departed(self, event: RelationDepartedEvent) -> None:
# likely due to a controller upgrade or a cloud maintenance with machines being reshuffled
# periodically, juju would emit a LeaderElected event, and would return no peer units
# the leader would then remove all other units from the quorum, which when restarted, would fail
if not event.departing_unit:
if not event.departing_unit or not self.model.app.planned_units():
return

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

Expand Down
2 changes: 2 additions & 0 deletions tests/integration/test_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ async def test_deploy_ssl_quorum(ops_test: OpsTest):
channel="edge",
num_units=1,
config={"ca-common-name": "zookeeper"},
revision=163,
),
)
await ops_test.model.add_relation(APP_NAME, TLS_NAME)
Expand Down Expand Up @@ -70,6 +71,7 @@ async def test_add_tls_provider_succeeds_after_removal(ops_test: OpsTest):
channel="edge",
num_units=1,
config={"ca-common-name": "zookeeper"},
revision=163,
),
)

Expand Down

0 comments on commit b6fc686

Please sign in to comment.