Skip to content

Commit

Permalink
Update grafana_dashboard.py
Browse files Browse the repository at this point in the history
Signed-off-by: Leon <[email protected]>
  • Loading branch information
sed-i authored Jan 22, 2025
1 parent 802a566 commit 2e91e91
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/charms/grafana_k8s/v0/grafana_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -1665,8 +1665,10 @@ def set_peer_data(self, key: str, data: Any) -> None:

def get_peer_data(self, key: str) -> Any:
"""Retrieve information from the peer data bucket instead of `StoredState`."""
data = self._charm.peers.data[self._charm.app].get(key, "") # type: ignore[attr-defined]
return json.loads(data) if data else {}
if rel := self._charm.peers:
data = rel.data[self._charm.app].get(key, "") # type: ignore[attr-defined]
return json.loads(data) if data else {}
return {}


class GrafanaDashboardAggregator(Object):
Expand Down

0 comments on commit 2e91e91

Please sign in to comment.