Skip to content

Commit

Permalink
[DPE-4303] Add fix for microceph testing workflow && update libs (#308)
Browse files Browse the repository at this point in the history
Updates libs and GH workflows to account for the microceph status check added in workflow v13.2.

Fixes #301
  • Loading branch information
phvalguima authored May 29, 2024
1 parent 60f1ced commit 1f799bb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
10 changes: 5 additions & 5 deletions lib/charms/data_platform_libs/v0/data_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down Expand Up @@ -642,16 +642,16 @@ 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:
self._secret_meta = self.add_secret(content, label=self.label)
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."""
Expand Down Expand Up @@ -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]):
Expand Down Expand Up @@ -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):
Expand Down
12 changes: 10 additions & 2 deletions lib/charms/tls_certificates_interface/v3/tls_certificates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down Expand Up @@ -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(
Expand All @@ -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}",
Expand Down

0 comments on commit 1f799bb

Please sign in to comment.