Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug introduced by #690 #742

Merged
merged 1 commit into from May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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