From df9eff462f966de60b2cf67b2f191c085988ed6d Mon Sep 17 00:00:00 2001 From: Mia Altieri Date: Tue, 25 Jun 2024 10:57:46 +0000 Subject: [PATCH 1/2] update workflow --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index dd63513e..8e046348 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -75,4 +75,4 @@ jobs: with: artifact-name: ${{ needs.build.outputs.artifact-name }} cloud: lxd - juju-agent-version: 3.1.6 + juju-agent-version: 3.1.7 From 48ad832e03c0b9b3b17c42115a3dc810e3477a54 Mon Sep 17 00:00:00 2001 From: Mia Altieri Date: Tue, 25 Jun 2024 11:34:15 +0000 Subject: [PATCH 2/2] hot fix for secrets fix --- lib/charms/mongodb/v0/mongodb_secrets.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/charms/mongodb/v0/mongodb_secrets.py b/lib/charms/mongodb/v0/mongodb_secrets.py index 6a1589c6..13d7f058 100644 --- a/lib/charms/mongodb/v0/mongodb_secrets.py +++ b/lib/charms/mongodb/v0/mongodb_secrets.py @@ -6,7 +6,7 @@ from ops import Secret, SecretInfo from ops.charm import CharmBase -from ops.model import SecretNotFoundError +from ops.model import ModelError, SecretNotFoundError from config import Config from exceptions import SecretAlreadyExistsError @@ -93,7 +93,21 @@ def get_content(self) -> Dict[str, str]: """Getting cached secret content.""" if not self._secret_content: if self.meta: - self._secret_content = self.meta.get_content() + try: + self._secret_content = self.meta.get_content(refresh=True) + except (ValueError, ModelError) as err: + # https://bugs.launchpad.net/juju/+bug/2042596 + # Only triggered when 'refresh' is set + known_model_errors = [ + "ERROR either URI or label should be used for getting an owned secret but not both", + "ERROR secret owner cannot use --refresh", + ] + if isinstance(err, ModelError) and not any( + msg in str(err) for msg in known_model_errors + ): + raise + # Due to: ValueError: Secret owner cannot use refresh=True + self._secret_content = self.meta.get_content() return self._secret_content def set_content(self, content: Dict[str, str]) -> None: