-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1430 from cybozu/grafana-operator-grafana-status-fix
grafana-operator: fix status of Grafana resources during reconciliation
- Loading branch information
Showing
3 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
5.10.0.1 | ||
5.10.0.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
diff --git a/controllers/dashboard_controller.go b/controllers/dashboard_controller.go | ||
index 1bd4b466..39a6781f 100644 | ||
--- a/controllers/dashboard_controller.go | ||
+++ b/controllers/dashboard_controller.go | ||
@@ -398,6 +398,11 @@ func (r *GrafanaDashboardReconciler) onDashboardCreated(ctx context.Context, gra | ||
} | ||
|
||
if exists && cr.Unchanged(hash) && !cr.ResyncPeriodHasElapsed() { | ||
+ if found, _ := grafana.Status.Dashboards.Find(cr.Namespace, cr.Name); !found { | ||
+ r.Log.Info("fixing inconsistent Grafana.status.dashboards filed", "grafana", map[string]string{"name": grafana.Name, "namespace": grafana.Namespace}) | ||
+ grafana.Status.Dashboards = grafana.Status.Dashboards.Add(cr.Namespace, cr.Name, uid) | ||
+ return r.Client.Status().Update(ctx, grafana) | ||
+ } | ||
return nil | ||
} | ||
|
||
@@ -407,6 +412,11 @@ func (r *GrafanaDashboardReconciler) onDashboardCreated(ctx context.Context, gra | ||
} | ||
|
||
if !remoteChanged { | ||
+ if found, _ := grafana.Status.Dashboards.Find(cr.Namespace, cr.Name); !found { | ||
+ r.Log.Info("fixing inconsistent Grafana.status.dashboards filed", "grafana", map[string]string{"name": grafana.Name, "namespace": grafana.Namespace}) | ||
+ grafana.Status.Dashboards = grafana.Status.Dashboards.Add(cr.Namespace, cr.Name, uid) | ||
+ return r.Client.Status().Update(ctx, grafana) | ||
+ } | ||
return nil | ||
} | ||
|
||
diff --git a/controllers/datasource_controller.go b/controllers/datasource_controller.go | ||
index cdf4e7ce..4f5753a7 100644 | ||
--- a/controllers/datasource_controller.go | ||
+++ b/controllers/datasource_controller.go | ||
@@ -335,6 +335,11 @@ func (r *GrafanaDatasourceReconciler) onDatasourceCreated(ctx context.Context, g | ||
} | ||
|
||
if exists && cr.Unchanged(hash) && !cr.ResyncPeriodHasElapsed() { | ||
+ if found, _ := grafana.Status.Datasources.Find(cr.Namespace, cr.Name); !found { | ||
+ r.Log.Info("fixing inconsistent Grafana.status.datasources filed", "grafana", map[string]string{"name": grafana.Name, "namespace": grafana.Namespace}) | ||
+ grafana.Status.Datasources = grafana.Status.Datasources.Add(cr.Namespace, cr.Name, datasource.UID) | ||
+ return r.Client.Status().Update(ctx, grafana) | ||
+ } | ||
return nil | ||
} | ||
|