From dcc34d7784b26d4f1d11a9da092d5575b85d4add Mon Sep 17 00:00:00 2001 From: Michael Dmitry <33381599+michaeldmitry@users.noreply.github.com> Date: Fri, 7 Feb 2025 08:51:26 +0200 Subject: [PATCH] Fix broken Nrpe dashboard (#389) * conditional popping * bump --- lib/charms/grafana_k8s/v0/grafana_dashboard.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/charms/grafana_k8s/v0/grafana_dashboard.py b/lib/charms/grafana_k8s/v0/grafana_dashboard.py index 5e87f726..9071e466 100644 --- a/lib/charms/grafana_k8s/v0/grafana_dashboard.py +++ b/lib/charms/grafana_k8s/v0/grafana_dashboard.py @@ -219,7 +219,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 = 40 +LIBPATCH = 41 PYDEPS = ["cosl >= 0.0.50"] @@ -633,7 +633,10 @@ def _replace_template_fields( # noqa: C901 deletions = [] for tmpl in dict_content["templating"]["list"]: if tmpl["name"] and tmpl["name"] in used_replacements: - deletions.append(tmpl) + # it might happen that existing template var name is the same as the one we insert (i.e prometheusds or lokids) + # in that case, we want to pop the existing one only. + if tmpl not in DATASOURCE_TEMPLATE_DROPDOWNS: + deletions.append(tmpl) for d in deletions: dict_content["templating"]["list"].remove(d)