From 1f799bb2420263f6b3e5d508f8dbfb3c29de9337 Mon Sep 17 00:00:00 2001 From: phvalguima Date: Wed, 29 May 2024 16:51:45 +0200 Subject: [PATCH] [DPE-4303] Add fix for microceph testing workflow && update libs (#308) Updates libs and GH workflows to account for the microceph status check added in workflow v13.2. Fixes #301 --- .github/workflows/ci.yaml | 6 +++--- .github/workflows/release.yaml | 4 ++-- lib/charms/data_platform_libs/v0/data_interfaces.py | 10 +++++----- .../v3/tls_certificates.py | 12 ++++++++++-- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index efe124379..57778f680 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,7 +16,7 @@ on: jobs: lint: name: Lint - uses: canonical/data-platform-workflows/.github/workflows/lint.yaml@v13.1.2 + uses: canonical/data-platform-workflows/.github/workflows/lint.yaml@v13.2.0 unit-test: name: Unit test charm @@ -61,7 +61,7 @@ jobs: path: - . - ./tests/integration/relations/opensearch_provider/application-charm/ - uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v13.1.2 + uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v13.2.0 with: path-to-charm-directory: ${{ matrix.path }} cache: true @@ -72,7 +72,7 @@ jobs: - lint - unit-test - build - uses: canonical/data-platform-workflows/.github/workflows/integration_test_charm.yaml@v13.1.2 + uses: canonical/data-platform-workflows/.github/workflows/integration_test_charm.yaml@v13.2.0 with: artifact-prefix: packed-charm-cache-true cloud: lxd diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d8317d97f..8c5d5d44b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -32,13 +32,13 @@ jobs: build: name: Build charm - uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v13.1.2 + uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v13.2.0 release: name: Release charm needs: - build - uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v13.1.2 + uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v13.2.0 with: channel: 2/edge artifact-prefix: ${{ needs.build.outputs.artifact-prefix }} diff --git a/lib/charms/data_platform_libs/v0/data_interfaces.py b/lib/charms/data_platform_libs/v0/data_interfaces.py index 5cb309b1f..b331bdce8 100644 --- a/lib/charms/data_platform_libs/v0/data_interfaces.py +++ b/lib/charms/data_platform_libs/v0/data_interfaces.py @@ -331,7 +331,7 @@ def _on_topic_requested(self, event: TopicRequestedEvent): # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 35 +LIBPATCH = 36 PYDEPS = ["ops>=2.0.0"] @@ -642,8 +642,8 @@ def _move_to_new_label_if_needed(self): return # Create a new secret with the new label - old_meta = self._secret_meta content = self._secret_meta.get_content() + self._secret_uri = None # I wish we could just check if we are the owners of the secret... try: @@ -651,7 +651,7 @@ def _move_to_new_label_if_needed(self): except ModelError as err: if "this unit is not the leader" not in str(err): raise - old_meta.remove_all_revisions() + self.current_label = None def set_content(self, content: Dict[str, str]) -> None: """Setting cached secret content.""" @@ -1586,7 +1586,7 @@ def _register_secret_to_relation( """ label = self._generate_secret_label(relation_name, relation_id, group) - # Fetchin the Secret's meta information ensuring that it's locally getting registered with + # Fetching the Secret's meta information ensuring that it's locally getting registered with CachedSecret(self._model, self.component, label, secret_id).meta def _register_secrets_to_relation(self, relation: Relation, params_name_list: List[str]): @@ -2309,7 +2309,7 @@ def _secrets(self) -> dict: return self._cached_secrets def _get_secret(self, group) -> Optional[Dict[str, str]]: - """Retrieveing secrets.""" + """Retrieving secrets.""" if not self.app: return if not self._secrets.get(group): diff --git a/lib/charms/tls_certificates_interface/v3/tls_certificates.py b/lib/charms/tls_certificates_interface/v3/tls_certificates.py index 6fa263973..2e45475a5 100644 --- a/lib/charms/tls_certificates_interface/v3/tls_certificates.py +++ b/lib/charms/tls_certificates_interface/v3/tls_certificates.py @@ -317,7 +317,7 @@ def _on_all_certificates_invalidated(self, event: AllCertificatesInvalidatedEven # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 13 +LIBPATCH = 14 PYDEPS = ["cryptography", "jsonschema"] @@ -1874,6 +1874,9 @@ def _on_relation_changed(self, event: RelationChangedEvent) -> None: if certificate.csr in requirer_csrs: if certificate.revoked: with suppress(SecretNotFoundError): + logger.debug( + "Removing secret with label %s", f"{LIBID}-{certificate.csr}" + ) secret = self.model.get_secret(label=f"{LIBID}-{certificate.csr}") secret.remove_all_revisions() self.on.certificate_invalidated.emit( @@ -1885,13 +1888,18 @@ def _on_relation_changed(self, event: RelationChangedEvent) -> None: ) else: try: + logger.debug( + "Setting secret with label %s", f"{LIBID}-{certificate.csr}" + ) secret = self.model.get_secret(label=f"{LIBID}-{certificate.csr}") secret.set_content({"certificate": certificate.certificate}) secret.set_info( expire=self._get_next_secret_expiry_time(certificate), ) except SecretNotFoundError: - logger.debug("Adding secret with label %s", f"{LIBID}-{certificate.csr}") + logger.debug( + "Creating new secret with label %s", f"{LIBID}-{certificate.csr}" + ) secret = self.charm.unit.add_secret( {"certificate": certificate.certificate}, label=f"{LIBID}-{certificate.csr}",