From b9f24b2e3ad3fa03e6f2adfbb813f576e65cda1b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 8 Jan 2025 16:27:22 +0200 Subject: [PATCH 1/2] Update data-platform-workflows to v24.0.6 (#814) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/ci.yaml | 6 +++--- .github/workflows/release.yaml | 4 ++-- .github/workflows/sync_docs.yaml | 2 +- poetry.lock | 18 +++++++++--------- pyproject.toml | 8 ++++---- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 53e53c6234..f3aa4670f8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,7 +23,7 @@ on: jobs: lint: name: Lint - uses: canonical/data-platform-workflows/.github/workflows/lint.yaml@v24.0.5 + uses: canonical/data-platform-workflows/.github/workflows/lint.yaml@v24.0.6 unit-test: name: Unit test charm @@ -45,7 +45,7 @@ jobs: build: name: Build charm - uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v24.0.5 + uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v24.0.6 with: cache: true @@ -71,7 +71,7 @@ jobs: - lint - unit-test - build - uses: canonical/data-platform-workflows/.github/workflows/integration_test_charm.yaml@v24.0.5 + uses: canonical/data-platform-workflows/.github/workflows/integration_test_charm.yaml@v24.0.6 with: artifact-prefix: ${{ needs.build.outputs.artifact-prefix }} architecture: ${{ matrix.architecture }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 5a67164f15..f2c404f53a 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -42,14 +42,14 @@ jobs: build: name: Build charm - uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v24.0.5 + uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v24.0.6 release: name: Release charm needs: - ci-tests - build - uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v24.0.5 + uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v24.0.6 with: channel: 14/edge artifact-prefix: ${{ needs.build.outputs.artifact-prefix }} diff --git a/.github/workflows/sync_docs.yaml b/.github/workflows/sync_docs.yaml index 7961316fa9..4fed57568c 100644 --- a/.github/workflows/sync_docs.yaml +++ b/.github/workflows/sync_docs.yaml @@ -10,7 +10,7 @@ on: jobs: sync-docs: name: Sync docs from Discourse - uses: canonical/data-platform-workflows/.github/workflows/sync_docs.yaml@v24.0.5 + uses: canonical/data-platform-workflows/.github/workflows/sync_docs.yaml@v24.0.6 with: reviewers: a-velasco permissions: diff --git a/poetry.lock b/poetry.lock index f01f60d5e5..6285726ce9 100644 --- a/poetry.lock +++ b/poetry.lock @@ -31,8 +31,8 @@ pytest = "*" [package.source] type = "git" url = "https://github.com/canonical/data-platform-workflows" -reference = "v24.0.5" -resolved_reference = "078fb649213bbffe223e826f04560c2e9c9c3396" +reference = "v24.0.6" +resolved_reference = "11c673f692893a15d15ee63469420e91f91f8a95" subdirectory = "python/pytest_plugins/allure_pytest_collection_report" [[package]] @@ -1752,8 +1752,8 @@ develop = false [package.source] type = "git" url = "https://github.com/canonical/data-platform-workflows" -reference = "v24.0.5" -resolved_reference = "078fb649213bbffe223e826f04560c2e9c9c3396" +reference = "v24.0.6" +resolved_reference = "11c673f692893a15d15ee63469420e91f91f8a95" subdirectory = "python/pytest_plugins/github_secrets" [[package]] @@ -1807,8 +1807,8 @@ pyyaml = "*" [package.source] type = "git" url = "https://github.com/canonical/data-platform-workflows" -reference = "v24.0.5" -resolved_reference = "078fb649213bbffe223e826f04560c2e9c9c3396" +reference = "v24.0.6" +resolved_reference = "11c673f692893a15d15ee63469420e91f91f8a95" subdirectory = "python/pytest_plugins/pytest_operator_cache" [[package]] @@ -1826,8 +1826,8 @@ pytest = "*" [package.source] type = "git" url = "https://github.com/canonical/data-platform-workflows" -reference = "v24.0.5" -resolved_reference = "078fb649213bbffe223e826f04560c2e9c9c3396" +reference = "v24.0.6" +resolved_reference = "11c673f692893a15d15ee63469420e91f91f8a95" subdirectory = "python/pytest_plugins/pytest_operator_groups" [[package]] @@ -2482,4 +2482,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "238c47e10ea3a12da28fc15bc9257df87cd0584e38ebad092a2fd8213544006f" +content-hash = "a3a92a9c28fa50cc3ab89a04046840cea55790620bffa77cad8c5a70153eadda" diff --git a/pyproject.toml b/pyproject.toml index 7f1a1d19bc..f3ecfbac4c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,11 +64,11 @@ optional = true [tool.poetry.group.integration.dependencies] lightkube = "^0.15.5" pytest = "^8.3.3" -pytest-github-secrets = {git = "https://github.com/canonical/data-platform-workflows", tag = "v24.0.5", subdirectory = "python/pytest_plugins/github_secrets"} +pytest-github-secrets = {git = "https://github.com/canonical/data-platform-workflows", tag = "v24.0.6", subdirectory = "python/pytest_plugins/github_secrets"} pytest-operator = "^0.38.0" -pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workflows", tag = "v24.0.5", subdirectory = "python/pytest_plugins/pytest_operator_cache"} -pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v24.0.5", subdirectory = "python/pytest_plugins/pytest_operator_groups"} -allure-pytest-collection-report = {git = "https://github.com/canonical/data-platform-workflows", tag = "v24.0.5", subdirectory = "python/pytest_plugins/allure_pytest_collection_report"} +pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workflows", tag = "v24.0.6", subdirectory = "python/pytest_plugins/pytest_operator_cache"} +pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v24.0.6", subdirectory = "python/pytest_plugins/pytest_operator_groups"} +allure-pytest-collection-report = {git = "https://github.com/canonical/data-platform-workflows", tag = "v24.0.6", subdirectory = "python/pytest_plugins/allure_pytest_collection_report"} # renovate caret doesn't work: https://github.com/renovatebot/renovate/issues/26940 juju = "<=3.5.2.1" psycopg2-binary = "^2.9.10" From de7429678fa5c7bb9f2f352bdbfbe2f8d8f788bd Mon Sep 17 00:00:00 2001 From: Dragomir Penev <6687393+dragomirp@users.noreply.github.com> Date: Wed, 8 Jan 2025 22:53:08 +0200 Subject: [PATCH 2/2] [MISC] Enable Juju 3.6 (#813) * TLS defer * Don't overwrite keys * Disable primary label tests --- .github/workflows/ci.yaml | 4 +- lib/charms/postgresql_k8s/v0/postgresql.py | 14 +++--- .../postgresql_k8s/v0/postgresql_tls.py | 22 ++++++--- poetry.lock | 48 +++++++++++-------- pyproject.toml | 2 +- .../ha_tests/test_rollback_to_master_label.py | 2 + .../ha_tests/test_upgrade_to_primary_label.py | 2 + 7 files changed, 57 insertions(+), 37 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f3aa4670f8..0951429f3c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -57,13 +57,13 @@ jobs: - agent: 2.9.51 # renovate: juju-agent-pin-minor libjuju: ==2.9.49.1 # renovate: latest libjuju 2 allure_on_amd64: false - - agent: 3.4.6 # renovate: juju-agent-pin-minor + - agent: 3.6.1 # renovate: juju-agent-pin-minor allure_on_amd64: true architecture: - amd64 include: - juju: - agent: 3.4.6 # renovate: juju-agent-pin-minor + agent: 3.6.1 # renovate: juju-agent-pin-minor allure_on_amd64: true architecture: arm64 name: Integration | ${{ matrix.juju.agent }} | ${{ matrix.architecture }} diff --git a/lib/charms/postgresql_k8s/v0/postgresql.py b/lib/charms/postgresql_k8s/v0/postgresql.py index 17adae9e61..986ae71f0d 100644 --- a/lib/charms/postgresql_k8s/v0/postgresql.py +++ b/lib/charms/postgresql_k8s/v0/postgresql.py @@ -21,7 +21,7 @@ import logging from collections import OrderedDict -from typing import Optional, Set, Tuple +from typing import List, Optional, Set, Tuple import psycopg2 from ops.model import Relation @@ -35,7 +35,7 @@ # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 40 +LIBPATCH = 41 INVALID_EXTRA_USER_ROLE_BLOCKING_MESSAGE = "invalid role(s) for extra user roles" @@ -108,7 +108,7 @@ def __init__( user: str, password: str, database: str, - system_users: Optional[list[str]] = None, + system_users: Optional[List[str]] = None, ): self.primary_host = primary_host self.current_host = current_host @@ -161,8 +161,8 @@ def create_database( self, database: str, user: str, - plugins: Optional[list[str]] = None, - client_relations: Optional[list[Relation]] = None, + plugins: Optional[List[str]] = None, + client_relations: Optional[List[Relation]] = None, ) -> None: """Creates a new database and grant privileges to a user on it. @@ -368,8 +368,8 @@ def enable_disable_extensions( connection.close() def _generate_database_privileges_statements( - self, relations_accessing_this_database: int, schemas: list[str], user: str - ) -> list[Composed]: + self, relations_accessing_this_database: int, schemas: List[str], user: str + ) -> List[Composed]: """Generates a list of databases privileges statements.""" statements = [] if relations_accessing_this_database == 1: diff --git a/lib/charms/postgresql_k8s/v0/postgresql_tls.py b/lib/charms/postgresql_k8s/v0/postgresql_tls.py index bdc7159a9d..5b2a0e937c 100644 --- a/lib/charms/postgresql_k8s/v0/postgresql_tls.py +++ b/lib/charms/postgresql_k8s/v0/postgresql_tls.py @@ -45,7 +45,7 @@ # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version. -LIBPATCH = 11 +LIBPATCH = 12 logger = logging.getLogger(__name__) SCOPE = "unit" @@ -130,11 +130,21 @@ def _on_certificate_available(self, event: CertificateAvailableEvent) -> None: logger.error("An unknown certificate available.") return - self.charm.set_secret( - SCOPE, "chain", "\n".join(event.chain) if event.chain is not None else None - ) - self.charm.set_secret(SCOPE, "cert", event.certificate) - self.charm.set_secret(SCOPE, "ca", event.ca) + if not event.certificate: + logger.debug("No certificate available.") + event.defer() + return + + chain = self.charm.get_secret(SCOPE, "chain") + new_chain = "\n".join(event.chain) if event.chain is not None else None + if chain != new_chain: + self.charm.set_secret(SCOPE, "chain", new_chain) + cert = self.charm.get_secret(SCOPE, "cert") + if cert != event.certificate: + self.charm.set_secret(SCOPE, "cert", event.certificate) + ca = self.charm.get_secret(SCOPE, "ca") + if ca != event.ca: + self.charm.set_secret(SCOPE, "ca", event.ca) try: if not self.charm.push_tls_files_to_workload(): diff --git a/poetry.lock b/poetry.lock index 6285726ce9..938630c7f6 100644 --- a/poetry.lock +++ b/poetry.lock @@ -120,6 +120,17 @@ files = [ {file = "backoff-2.2.1.tar.gz", hash = "sha256:03f829f5bb1923180821643f8753b0502c3b682293992485b0eef2807afa5cba"}, ] +[[package]] +name = "backports-strenum" +version = "1.3.1" +description = "Base class for creating enumerated constants that are also subclasses of str" +optional = false +python-versions = ">=3.8.6,<3.11" +files = [ + {file = "backports_strenum-1.3.1-py3-none-any.whl", hash = "sha256:cdcfe36dc897e2615dc793b7d3097f54d359918fc448754a517e6f23044ccf83"}, + {file = "backports_strenum-1.3.1.tar.gz", hash = "sha256:77c52407342898497714f0596e86188bb7084f89063226f4ba66863482f42414"}, +] + [[package]] name = "bcrypt" version = "4.2.1" @@ -612,17 +623,6 @@ wrapt = ">=1.10,<2" [package.extras] dev = ["PyTest", "PyTest-Cov", "bump2version (<1)", "jinja2 (>=3.0.3,<3.1.0)", "setuptools", "sphinx (<2)", "tox"] -[[package]] -name = "durationpy" -version = "0.9" -description = "Module for converting between datetime.timedelta and Go's Duration strings." -optional = false -python-versions = "*" -files = [ - {file = "durationpy-0.9-py3-none-any.whl", hash = "sha256:e65359a7af5cedad07fb77a2dd3f390f8eb0b74cb845589fa6c057086834dd38"}, - {file = "durationpy-0.9.tar.gz", hash = "sha256:fd3feb0a69a0057d582ef643c355c40d2fa1c942191f914d12203b1a01ac722a"}, -] - [[package]] name = "exceptiongroup" version = "1.2.2" @@ -947,17 +947,19 @@ referencing = ">=0.31.0" [[package]] name = "juju" -version = "3.5.2.1" +version = "3.6.1.0" description = "Python library for Juju" optional = false -python-versions = "*" +python-versions = ">=3.8.6" files = [ - {file = "juju-3.5.2.1.tar.gz", hash = "sha256:112da798b058d7cb23caffc5868c5c51e5f8a422ee1ab20006a090d396b90b0e"}, + {file = "juju-3.6.1.0-py3-none-any.whl", hash = "sha256:28b6a10093f2e0243ad0ddd5ef25a3f59d710e9da5a188456ba704142819fbb3"}, + {file = "juju-3.6.1.0.tar.gz", hash = "sha256:59cfde55185bb53877a2bddc2855f3c48471537e130653d77984681676a448bc"}, ] [package.dependencies] +"backports.strenum" = {version = ">=1.3.1", markers = "python_version < \"3.11\""} hvac = "*" -kubernetes = ">=12.0.1" +kubernetes = ">=12.0.1,<31.0.0" macaroonbakery = ">=1.1,<2.0" packaging = "*" paramiko = ">=2.4.0" @@ -965,23 +967,27 @@ pyasn1 = ">=0.4.4" pyRFC3339 = ">=1.0,<2.0" pyyaml = ">=5.1.2" toposort = ">=1.5,<2" +typing-extensions = ">=4.5.0" typing_inspect = ">=0.6.0" -websockets = ">=8.1,<14.0" +websockets = ">=13.0.1" + +[package.extras] +dev = ["Twine", "freezegun", "pytest", "pytest-asyncio", "typing-inspect"] +docs = ["sphinx (==5.3.0)", "sphinx_rtd_theme", "sphinxcontrib-asyncio"] [[package]] name = "kubernetes" -version = "31.0.0" +version = "30.1.0" description = "Kubernetes python client" optional = false python-versions = ">=3.6" files = [ - {file = "kubernetes-31.0.0-py2.py3-none-any.whl", hash = "sha256:bf141e2d380c8520eada8b351f4e319ffee9636328c137aa432bc486ca1200e1"}, - {file = "kubernetes-31.0.0.tar.gz", hash = "sha256:28945de906c8c259c1ebe62703b56a03b714049372196f854105afe4e6d014c0"}, + {file = "kubernetes-30.1.0-py2.py3-none-any.whl", hash = "sha256:e212e8b7579031dd2e512168b617373bc1e03888d41ac4e04039240a292d478d"}, + {file = "kubernetes-30.1.0.tar.gz", hash = "sha256:41e4c77af9f28e7a6c314e3bd06a8c6229ddd787cad684e0ab9f69b498e98ebc"}, ] [package.dependencies] certifi = ">=14.05.14" -durationpy = ">=0.7" google-auth = ">=1.0.1" oauthlib = ">=3.2.2" python-dateutil = ">=2.5.3" @@ -2482,4 +2488,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "a3a92a9c28fa50cc3ab89a04046840cea55790620bffa77cad8c5a70153eadda" +content-hash = "4c422a90dd4a96409c8a0a6720c61e7da3b109d7832a16a0ba8ffedfaf13f8b0" diff --git a/pyproject.toml b/pyproject.toml index f3ecfbac4c..43caafd894 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,7 +70,7 @@ pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workf pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v24.0.6", subdirectory = "python/pytest_plugins/pytest_operator_groups"} allure-pytest-collection-report = {git = "https://github.com/canonical/data-platform-workflows", tag = "v24.0.6", subdirectory = "python/pytest_plugins/allure_pytest_collection_report"} # renovate caret doesn't work: https://github.com/renovatebot/renovate/issues/26940 -juju = "<=3.5.2.1" +juju = "<=3.6.1.0" psycopg2-binary = "^2.9.10" boto3 = "^1.35.70" tenacity = "^9.0.0" diff --git a/tests/integration/ha_tests/test_rollback_to_master_label.py b/tests/integration/ha_tests/test_rollback_to_master_label.py index 8b6e3f29d9..7e6639b0ad 100644 --- a/tests/integration/ha_tests/test_rollback_to_master_label.py +++ b/tests/integration/ha_tests/test_rollback_to_master_label.py @@ -38,6 +38,7 @@ @pytest.mark.group(1) @markers.juju3 +@pytest.mark.unstable @markers.amd64_only # TODO: remove after arm64 stable release @pytest.mark.abort_on_fail async def test_deploy_stable(ops_test: OpsTest) -> None: @@ -72,6 +73,7 @@ async def test_deploy_stable(ops_test: OpsTest) -> None: @pytest.mark.group(1) @markers.juju3 +@pytest.mark.unstable @markers.amd64_only # TODO: remove after arm64 stable release async def test_fail_and_rollback(ops_test, continuous_writes) -> None: # Start an application that continuously writes data to the database. diff --git a/tests/integration/ha_tests/test_upgrade_to_primary_label.py b/tests/integration/ha_tests/test_upgrade_to_primary_label.py index e8d3e42e64..0d76c08f2b 100644 --- a/tests/integration/ha_tests/test_upgrade_to_primary_label.py +++ b/tests/integration/ha_tests/test_upgrade_to_primary_label.py @@ -36,6 +36,7 @@ @pytest.mark.group(1) @markers.amd64_only # TODO: remove after arm64 stable release +@pytest.mark.unstable @pytest.mark.abort_on_fail async def test_deploy_stable(ops_test: OpsTest) -> None: """Simple test to ensure that the PostgreSQL and application charms get deployed.""" @@ -75,6 +76,7 @@ async def test_deploy_stable(ops_test: OpsTest) -> None: @pytest.mark.group(1) @markers.amd64_only # TODO: remove after arm64 stable release +@pytest.mark.unstable async def test_upgrade(ops_test, continuous_writes) -> None: # Start an application that continuously writes data to the database. logger.info("starting continuous writes to the database")