Skip to content

Commit

Permalink
Fix bug introduced by #690 (#742)
Browse files Browse the repository at this point in the history
  • Loading branch information
addreas committed May 6, 2022
1 parent ebced34 commit 03acb04
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 8 additions & 9 deletions controllers/config/controller_config.go
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion controllers/grafana/grafana_controller.go
Expand Up @@ -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{}
Expand Down

0 comments on commit 03acb04

Please sign in to comment.