diff --git a/controllers/config/controller_config.go b/controllers/config/controller_config.go index f6fe8231d..4a65e9603 100644 --- a/controllers/config/controller_config.go +++ b/controllers/config/controller_config.go @@ -158,16 +158,15 @@ func (c *ControllerConfig) GetDashboards(namespace string) []*v1alpha1.GrafanaDa return c.Dashboards[namespace] } - return []*v1alpha1.GrafanaDashboardRef{} -} - -func (c *ControllerConfig) GetAllDashboards() []*v1alpha1.GrafanaDashboardRef { - c.Lock() - defer c.Unlock() + dashboards := []*v1alpha1.GrafanaDashboardRef{} - var dashboards []*v1alpha1.GrafanaDashboardRef - for _, ds := range c.Dashboards { - dashboards = append(dashboards, ds...) + // The periodic resync in grafanadashboard.GrafanaDashboardReconciler rely on the convention + // that an empty namespace means all of them, so we follow that rule here. + if namespace == "" { + for _, ds := range c.Dashboards { + dashboards = append(dashboards, ds...) + } + return dashboards } return dashboards diff --git a/controllers/grafana/grafana_controller.go b/controllers/grafana/grafana_controller.go index 54556e489..7fac7f1dc 100644 --- a/controllers/grafana/grafana_controller.go +++ b/controllers/grafana/grafana_controller.go @@ -283,7 +283,7 @@ func (r *ReconcileGrafana) manageSuccess(cr *grafanav1alpha1.Grafana, state *com // Only update the status if the dashboard controller had a chance to sync the cluster // dashboards first. Otherwise reuse the existing dashboard config from the CR. if r.Config.GetConfigBool(config.ConfigGrafanaDashboardsSynced, false) { - cr.Status.InstalledDashboards = r.Config.GetAllDashboards() + cr.Status.InstalledDashboards = r.Config.GetDashboards("") } instance := &grafanav1alpha1.Grafana{}