From c1343183033465cdd32004e6e7f23d1405055568 Mon Sep 17 00:00:00 2001 From: michael Date: Wed, 11 Dec 2024 16:10:13 +0200 Subject: [PATCH] fetch lib --- lib/charms/grafana_k8s/v0/grafana_source.py | 15 ++++++--------- src/charm.py | 3 +++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/charms/grafana_k8s/v0/grafana_source.py b/lib/charms/grafana_k8s/v0/grafana_source.py index 774bcd7e..6e09c508 100644 --- a/lib/charms/grafana_k8s/v0/grafana_source.py +++ b/lib/charms/grafana_k8s/v0/grafana_source.py @@ -154,8 +154,6 @@ def __init__(self, *args): ) from ops.model import Relation -from charms.observability_libs.v0.juju_topology import JujuTopology - # The unique Charmhub library identifier, never change it LIBID = "974705adb86f40228298156e34b460dc" @@ -164,7 +162,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 = 23 +LIBPATCH = 24 logger = logging.getLogger(__name__) @@ -579,12 +577,11 @@ def _publish_source_uids(self, rel: Relation, uids: Dict[str, str]): Assumes only leader unit will call this method """ - juju_topology = JujuTopology.from_charm(self._charm) unique_grafana_name = "juju_{}_{}_{}_{}".format( - juju_topology.model, - juju_topology.model_uuid, - juju_topology.application, - juju_topology.unit.split("/")[1], + self._charm.model.name, + self._charm.model.uuid, + self._charm.model.app.name, + self._charm.model.unit.name.split("/")[1], # type: ignore ) rel.data[self._charm.app]["grafana_uid"] = unique_grafana_name @@ -802,4 +799,4 @@ def get_peer_data(self, key: str) -> Any: return {} data = self._charm.peers.data[self._charm.app].get(key, "") # type: ignore[attr-defined] - return json.loads(data) if data else {} \ No newline at end of file + return json.loads(data) if data else {} diff --git a/src/charm.py b/src/charm.py index 44ebc3cc..c237f8a7 100755 --- a/src/charm.py +++ b/src/charm.py @@ -1119,6 +1119,9 @@ def _push(self, path, contents): def _update_datasource_exchange(self) -> None: """Update the grafana-datasource-exchange relations.""" + if not self.unit.is_leader(): + return + grafana_uids_to_units_to_uids = self.grafana_source_provider.get_source_uids() raw_datasources: List[DatasourceDict] = []