diff --git a/CHANGELOG.md b/CHANGELOG.md index e0fdaef1..eeb7f4fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - improved run-local port-forward management +### Fixed + +- fixed loading dashboards when they have an `id` defined + ### Removed - Remove turtle related Alertmanager configuration diff --git a/internal/controller/dashboard_controller.go b/internal/controller/dashboard_controller.go index 663c40bb..b9aafb7b 100644 --- a/internal/controller/dashboard_controller.go +++ b/internal/controller/dashboard_controller.go @@ -174,6 +174,12 @@ func getDashboardUID(dashboard map[string]interface{}) (string, error) { return UID, nil } +func cleanDashboardID(dashboard map[string]interface{}) { + if dashboard["id"] != nil { + delete(dashboard, "id") + } +} + func getOrgFromDashboardConfigmap(dashboard *v1.ConfigMap) (string, error) { // Try to look for an annotation first annotations := dashboard.GetAnnotations() @@ -232,6 +238,9 @@ func (r DashboardReconciler) configureDashboard(ctx context.Context, dashboardCM continue } + // Clean the dashboard ID to avoid conflicts + cleanDashboardID(dashboard) + // Create or update dashboard err = grafana.PublishDashboard(r.GrafanaAPI, dashboard) if err != nil { @@ -292,6 +301,9 @@ func (r DashboardReconciler) reconcileDelete(ctx context.Context, dashboardCM *v continue } + // Clean the dashboard ID to avoid conflicts + cleanDashboardID(dashboard) + _, err = r.GrafanaAPI.Dashboards.GetDashboardByUID(dashboardUID) if err != nil { logger.Error(err, "Failed getting dashboard")