Skip to content

Commit 3d7f1a0

Browse files
Update data-platform-workflows to v7.0.0 (#95)
Fix broken build CI
1 parent 240ad96 commit 3d7f1a0

File tree

7 files changed

+37
-16
lines changed

7 files changed

+37
-16
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363

6464
build:
6565
name: Build charms
66-
uses: canonical/data-platform-workflows/.github/workflows/build_charms_with_cache.yaml@v5.0.1
66+
uses: canonical/data-platform-workflows/.github/workflows/build_charms_with_cache.yaml@v7.0.0
6767
permissions:
6868
actions: write # Needed to manage GitHub Actions cache
6969

.github/workflows/release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ jobs:
1717

1818
build:
1919
name: Build charm
20-
uses: canonical/data-platform-workflows/.github/workflows/build_charm_without_cache.yaml@v5.0.1
20+
uses: canonical/data-platform-workflows/.github/workflows/build_charm_without_cache.yaml@v7.0.0
2121

2222
release:
2323
name: Release charm
2424
needs:
2525
- ci-tests
2626
- build
27-
uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v5.0.1
27+
uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v7.0.0
2828
with:
2929
channel: dpe/edge
3030
artifact-name: ${{ needs.build.outputs.artifact-name }}

.github/workflows/sync_issue_to_jira.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
jobs:
1010
sync:
1111
name: Sync GitHub issue to Jira
12-
uses: canonical/data-platform-workflows/.github/workflows/sync_issue_to_jira.yaml@v5.0.1
12+
uses: canonical/data-platform-workflows/.github/workflows/sync_issue_to_jira.yaml@v7.0.0
1313
with:
1414
jira-base-url: https://warthogs.atlassian.net
1515
jira-project-key: DPE

lib/charms/data_platform_libs/v0/data_interfaces.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ def _on_topic_requested(self, event: TopicRequestedEvent):
320320

321321
# Increment this PATCH version before using `charmcraft publish-lib` or reset
322322
# to 0 if you are raising the major API version
323-
LIBPATCH = 23
323+
LIBPATCH = 24
324324

325325
PYDEPS = ["ops>=2.0.0"]
326326

@@ -526,7 +526,16 @@ def get_content(self) -> Dict[str, str]:
526526
"""Getting cached secret content."""
527527
if not self._secret_content:
528528
if self.meta:
529-
self._secret_content = self.meta.get_content()
529+
try:
530+
self._secret_content = self.meta.get_content(refresh=True)
531+
except (ValueError, ModelError) as err:
532+
# https://bugs.launchpad.net/juju/+bug/2042596
533+
# Only triggered when 'refresh' is set
534+
msg = "ERROR either URI or label should be used for getting an owned secret but not both"
535+
if isinstance(err, ModelError) and msg not in str(err):
536+
raise
537+
# Due to: ValueError: Secret owner cannot use refresh=True
538+
self._secret_content = self.meta.get_content()
530539
return self._secret_content
531540

532541
def set_content(self, content: Dict[str, str]) -> None:
@@ -1085,7 +1094,7 @@ def _delete_relation_secret(
10851094
secret = self._get_relation_secret(relation.id, group)
10861095

10871096
if not secret:
1088-
logging.error("Can't update secret for relation %s", str(relation.id))
1097+
logging.error("Can't delete secret for relation %s", str(relation.id))
10891098
return False
10901099

10911100
old_content = secret.get_content()
@@ -1827,7 +1836,8 @@ def _assign_relation_alias(self, relation_id: int) -> None:
18271836

18281837
# We need to set relation alias also on the application level so,
18291838
# it will be accessible in show-unit juju command, executed for a consumer application unit
1830-
self.update_relation_data(relation_id, {"alias": available_aliases[0]})
1839+
if self.local_unit.is_leader():
1840+
self.update_relation_data(relation_id, {"alias": available_aliases[0]})
18311841

18321842
def _emit_aliased_event(self, event: RelationChangedEvent, event_name: str) -> None:
18331843
"""Emit an aliased event to a particular relation if it has an alias.
@@ -1914,6 +1924,9 @@ def _on_relation_created_event(self, event: RelationCreatedEvent) -> None:
19141924

19151925
# Sets both database and extra user roles in the relation
19161926
# if the roles are provided. Otherwise, sets only the database.
1927+
if not self.local_unit.is_leader():
1928+
return
1929+
19171930
if self.extra_user_roles:
19181931
self.update_relation_data(
19191932
event.relation.id,
@@ -2173,6 +2186,9 @@ def _on_relation_created_event(self, event: RelationCreatedEvent) -> None:
21732186
"""Event emitted when the Kafka relation is created."""
21742187
super()._on_relation_created_event(event)
21752188

2189+
if not self.local_unit.is_leader():
2190+
return
2191+
21762192
# Sets topic, extra user roles, and "consumer-group-prefix" in the relation
21772193
relation_data = {
21782194
f: getattr(self, f.replace("-", "_"), "")
@@ -2345,6 +2361,9 @@ def _on_relation_created_event(self, event: RelationCreatedEvent) -> None:
23452361
"""Event emitted when the OpenSearch relation is created."""
23462362
super()._on_relation_created_event(event)
23472363

2364+
if not self.local_unit.is_leader():
2365+
return
2366+
23482367
# Sets both index and extra user roles in the relation if the roles are provided.
23492368
# Otherwise, sets only the index.
23502369
data = {"index": self.index}

poetry.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ pytest-mock = "^3.11.1"
5050
[tool.poetry.group.integration.dependencies]
5151
pytest = "^7.4.0"
5252
pytest-operator = "^0.28.0"
53-
pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workflows", tag = "v5.0.1", subdirectory = "python/pytest_plugins/pytest_operator_cache"}
54-
pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v5.0.1", subdirectory = "python/pytest_plugins/pytest_operator_groups"}
53+
pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workflows", tag = "v7.0.0", subdirectory = "python/pytest_plugins/pytest_operator_cache"}
54+
pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v7.0.0", subdirectory = "python/pytest_plugins/pytest_operator_groups"}
5555
juju = "3.2.0.1"
5656
mysql-connector-python = "~8.0.33"
5757
tenacity = "^8.2.2"

tox.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ allowlist_externals =
1919

2020
[testenv:{build,pack-wrapper}]
2121
# Wrap `charmcraft pack`
22+
pass_env =
23+
CRAFT_SHARED_CACHE
2224
allowlist_externals =
2325
{[testenv]allowlist_externals}
2426
charmcraft

0 commit comments

Comments
 (0)