Skip to content

Commit

Permalink
Use dashboard relpath for the hash
Browse files Browse the repository at this point in the history
  • Loading branch information
sed-i committed Dec 16, 2024
1 parent 3672ddb commit 513163a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/charms/grafana_k8s/v0/grafana_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,11 @@ def _is_dashboard(p: Path) -> bool:
_encode_dashboard_content(path.read_bytes()), inject_dropdowns
)
stored_dashboard_templates[id]["dashboard_alt_uid"] = self._generate_alt_uid(
str(path)
# We want the relative path to charm dir, to avoid hashing parts of the unit name, e.g.
# /var/lib/juju/agents/unit-ga-9/charm/grafana_dashboards/node-exporter-full.json
# With a relative path, the same dashboard coming from multiple instances of the same app would have
# the same UID, which is what we want.
str(path.relative_to(self._charm.charm_dir))
)

self._stored.dashboard_templates = stored_dashboard_templates
Expand Down

0 comments on commit 513163a

Please sign in to comment.