Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion lib/charms/data_platform_libs/v0/data_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ def _on_subject_requested(self, event: SubjectRequestedEvent):

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 56
LIBPATCH = 58

PYDEPS = ["ops>=2.0.0"]

Expand Down Expand Up @@ -842,6 +842,11 @@ def _legacy_compat_find_secret_by_old_label(self) -> None:
self._secret_meta = self._model.get_secret(label=label)
except SecretNotFoundError:
pass
except ModelError as e:
# Permission denied can be raised if the secret exists but is not yet granted to us.
if "permission denied" in str(e):
return
raise
else:
if label != self.label:
self.current_label = label
Expand Down Expand Up @@ -876,6 +881,8 @@ def _legacy_migration_to_new_label_if_needed(self) -> None:
except ModelError as err:
if MODEL_ERRORS["not_leader"] not in str(err):
raise
if "permission denied" not in str(err):
raise
self.current_label = None

##########################################################################
Expand Down Expand Up @@ -4268,6 +4275,14 @@ def _on_secret_changed_event(self, event: SecretChangedEvent):
if relation.app == self.charm.app:
logging.info("Secret changed event ignored for Secret Owner")

if relation.name != self.relation_data.relation_name:
logger.debug(
"Ignoring secret-changed from endpoint %s (expected %s)",
relation.name,
self.relation_data.relation_name,
)
return

remote_unit = None
for unit in relation.units:
if unit.app != self.charm.app:
Expand Down Expand Up @@ -5294,6 +5309,14 @@ def _on_secret_changed_event(self, event: SecretChangedEvent):
)
return

if relation.name != self.relation_data.relation_name:
logger.debug(
"Ignoring secret-changed from endpoint %s (expected %s)",
relation.name,
self.relation_data.relation_name,
)
return

if relation.app == self.charm.app:
logging.info("Secret changed event ignored for Secret Owner")

Expand Down Expand Up @@ -5556,6 +5579,14 @@ def _on_secret_changed_event(self, event: SecretChangedEvent):
)
return

if relation.name != self.relation_data.relation_name:
logger.debug(
"Ignoring secret-changed from endpoint %s (expected %s)",
relation.name,
self.relation_data.relation_name,
)
return

if relation.app == self.charm.app:
logging.info("Secret changed event ignored for Secret Owner")

Expand Down Expand Up @@ -5701,6 +5732,14 @@ def _on_secret_changed_event(self, event: SecretChangedEvent):
if relation.app == self.charm.app:
logging.info("Secret changed event ignored for Secret Owner")

if relation.name != self.relation_data.relation_name:
logger.debug(
"Ignoring secret-changed from endpoint %s (expected %s)",
relation.name,
self.relation_data.relation_name,
)
return

remote_unit = None
for unit in relation.units:
if unit.app != self.charm.app:
Expand Down
16 changes: 13 additions & 3 deletions lib/charms/grafana_k8s/v0/grafana_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def __init__(self, *args):
# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version

LIBPATCH = 47
LIBPATCH = 49

PYDEPS = ["cosl >= 0.0.50"]

Expand Down Expand Up @@ -585,9 +585,19 @@ def _convert_dashboard_fields(cls, content: str, inject_dropdowns: bool = True)
datasources[template_value["name"]] = template_value["query"].lower()

# Put our own variables in the template
# We only want to inject our own dropdowns IFF they are NOT
# already in the template coming over relation data.
# We'll store all dropdowns in the template from the provider
# in a set. We'll add our own if they are not in this set.
existing_names = {
item.get("name")
for item in dict_content["templating"]["list"]
}

for d in template_dropdowns: # type: ignore
if d not in dict_content["templating"]["list"]:
if d.get("name") not in existing_names:
dict_content["templating"]["list"].insert(0, d)
existing_names.add(d.get("name"))

dict_content = cls._replace_template_fields(dict_content, datasources, existing_templates)
return json.dumps(dict_content)
Expand Down Expand Up @@ -1003,7 +1013,7 @@ def _is_dashboard(p: Path) -> bool:

dashboard_templates = {}

for path in filter(_is_dashboard, Path(dashboards_path).glob("*")):
for path in filter(_is_dashboard, Path(dashboards_path).glob("**/*")):
try:
dashboard_dict = json.loads(path.read_bytes())
except json.JSONDecodeError as e:
Expand Down
Loading