Skip to content

Commit

Permalink
[DPE-3112] Fix DEPENDENCIES field mismatch (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
deusebio authored Dec 11, 2023
1 parent c43c5bb commit 6218126
Show file tree
Hide file tree
Showing 9 changed files with 264 additions and 260 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:

build:
name: Build charms
uses: canonical/data-platform-workflows/.github/workflows/build_charms_with_cache.yaml@v2
uses: canonical/data-platform-workflows/.github/workflows/build_charms_with_cache.yaml@v7

integration-test:
strategy:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ jobs:

build:
name: Build charm
uses: canonical/data-platform-workflows/.github/workflows/build_charm_without_cache.yaml@v2
uses: canonical/data-platform-workflows/.github/workflows/build_charm_without_cache.yaml@v7

release:
name: Release to Charmhub
needs:
- lib-check
- ci-tests
- build
uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v2
uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v7
with:
channel: 3/edge
artifact-name: ${{ needs.build.outputs.artifact-name }}
Expand Down
440 changes: 228 additions & 212 deletions poetry.lock

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ description = "zookeeper-operator"
authors = []

[tool.poetry.dependencies]
python = ">=3.8"
python = ">=3.8,<4.0"
ops = "^2.4.1"
kazoo = ">=2.8.0"
tenacity = ">=8.0.1"
Expand Down Expand Up @@ -71,6 +71,9 @@ pytest = ">=7.2"
juju = "^3.2.0"
coverage = {extras = ["toml"], version = ">7.0"}
pytest-operator = ">0.20"
pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workflows", tag = "v6.1.1", subdirectory = "python/pytest_plugins/pytest_operator_cache"}
# To be enabled if we are using groups on integration tests
# pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v6.1.1", subdirectory = "python/pytest_plugins/pytest_operator_groups"}

[tool.ruff]
line-length = 99
Expand Down
26 changes: 13 additions & 13 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
cffi==1.15.1 ; python_version >= "3.8"
cosl==0.0.5 ; python_version >= "3.8"
cryptography==39.0.2 ; python_version >= "3.8"
kazoo==2.9.0 ; python_version >= "3.8"
ops==2.5.0 ; python_version >= "3.8"
pure-sasl==0.6.2 ; python_version >= "3.8"
pycparser==2.21 ; python_version >= "3.8"
pydantic==1.10.12 ; python_version >= "3.8"
pyyaml==6.0.1 ; python_version >= "3.8"
six==1.16.0 ; python_version >= "3.8"
tenacity==8.2.2 ; python_version >= "3.8"
typing-extensions==4.7.1 ; python_version >= "3.8"
websocket-client==1.6.1 ; python_version >= "3.8"
cffi==1.16.0 ; python_version >= "3.8" and python_version < "4.0"
cosl==0.0.7 ; python_version >= "3.8" and python_version < "4.0"
cryptography==39.0.2 ; python_version >= "3.8" and python_version < "4.0"
kazoo==2.9.0 ; python_version >= "3.8" and python_version < "4.0"
ops==2.9.0 ; python_version >= "3.8" and python_version < "4.0"
pure-sasl==0.6.2 ; python_version >= "3.8" and python_version < "4.0"
pycparser==2.21 ; python_version >= "3.8" and python_version < "4.0"
pydantic==1.10.13 ; python_version >= "3.8" and python_version < "4.0"
pyyaml==6.0.1 ; python_version >= "3.8" and python_version < "4.0"
six==1.16.0 ; python_version >= "3.8" and python_version < "4.0"
tenacity==8.2.3 ; python_version >= "3.8" and python_version < "4.0"
typing-extensions==4.8.0 ; python_version >= "3.8" and python_version < "4.0"
websocket-client==1.7.0 ; python_version >= "3.8" and python_version < "4.0"
2 changes: 1 addition & 1 deletion src/literals.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
"dependencies": {},
"name": "zookeeper",
"upgrade_supported": "^3.5",
"version": "3.6.4",
"version": "3.8.2",
},
}
12 changes: 11 additions & 1 deletion src/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""Manager for handling ZooKeeper in-place upgrades."""

import logging
import time
from functools import cached_property
from typing import TYPE_CHECKING

Expand All @@ -19,6 +20,7 @@
)
from kazoo.client import ConnectionClosedError
from pydantic import BaseModel
from tenacity import retry, stop_after_attempt, wait_random
from typing_extensions import override

if TYPE_CHECKING:
Expand Down Expand Up @@ -59,6 +61,7 @@ def client(self) -> ZooKeeperManager:
password=self.charm.cluster.passwords[0],
)

@retry(stop=stop_after_attempt(5), wait=wait_random(min=1, max=5), reraise=True)
def post_upgrade_check(self) -> None:
"""Runs necessary checks validating the unit is in a healthy state after upgrade."""
self.pre_upgrade_check()
Expand All @@ -70,29 +73,34 @@ def pre_upgrade_check(self) -> None:
if not self.client.members_broadcasting or not len(self.client.server_members) == len(
self.charm.cluster.peer_units
):
logger.info("Check failed: broadcasting error")
raise ClusterNotReadyError(
message=default_message,
cause="Not all application units are connected and broadcasting in the quorum",
)

if self.client.members_syncing:
logger.info("Check failed: quorum members syncing")
raise ClusterNotReadyError(
message=default_message, cause="Some quorum members are syncing data"
)

if not self.charm.cluster.stable:
logger.info("Check failed: cluster initializing")
raise ClusterNotReadyError(
message=default_message, cause="Charm has not finished initialising"
)

except QuorumLeaderNotFoundError:
logger.info("Check failed: Quorum leader not found")
raise ClusterNotReadyError(message=default_message, cause="Quorum leader not found")
except ConnectionClosedError:
logger.info("Check failed: Unable to connect to the cluster")
raise ClusterNotReadyError(
message=default_message, cause="Unable to connect to the cluster"
)
except Exception as e:
logger.debug(str(e))
logger.info(f"Check failed: Unknown error: {e}")
raise ClusterNotReadyError(message=default_message, cause="Unknown error")

@override
Expand Down Expand Up @@ -134,6 +142,8 @@ def _on_upgrade_granted(self, event: UpgradeGrantedEvent) -> None:
logger.info(f"{self.charm.unit.name} upgrading service...")
self.charm.snap.restart_snap_service()

time.sleep(5.0)

try:
logger.debug("Running post-upgrade check...")
self.post_upgrade_check()
Expand Down
28 changes: 0 additions & 28 deletions tests/integration/conftest.py

This file was deleted.

5 changes: 4 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,13 @@ commands =

[testenv:integration-{provider,password-rotation,tls,upgrade,ha,replication}]
description = Run integration tests
set_env =
{[testenv]set_env}
# Workaround for https://github.com/python-poetry/poetry/issues/6958
POETRY_INSTALLER_PARALLEL = false
pass_env =
{[testenv]pass_env}
CI
CI_PACKED_CHARMS
commands =
poetry install --with integration
poetry run pytest -vv --tb native --log-cli-level=INFO -s {posargs} {[vars]tests_path}/integration/{env:TEST_FILE}

0 comments on commit 6218126

Please sign in to comment.