Skip to content

Commit

Permalink
fetch lib
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldmitry committed Dec 11, 2024
1 parent 1806983 commit c134318
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
15 changes: 6 additions & 9 deletions lib/charms/grafana_k8s/v0/grafana_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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__)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {}
return json.loads(data) if data else {}
3 changes: 3 additions & 0 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] = []

Expand Down

0 comments on commit c134318

Please sign in to comment.