From b84ccbdf901bbf932160c1357f11f967653c0baa Mon Sep 17 00:00:00 2001 From: Peter Braun Date: Tue, 6 Aug 2019 18:11:44 +0200 Subject: [PATCH] detect resources from a previous installation --- pkg/controller/grafanadashboard/dashboard_controller.go | 9 +++++++-- .../grafanadatasource/datasource_controller.go | 8 +++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/pkg/controller/grafanadashboard/dashboard_controller.go b/pkg/controller/grafanadashboard/dashboard_controller.go index efceedf9e..62a819cb6 100644 --- a/pkg/controller/grafanadashboard/dashboard_controller.go +++ b/pkg/controller/grafanadashboard/dashboard_controller.go @@ -120,7 +120,13 @@ func (r *ReconcileGrafanaDashboard) Reconcile(request reconcile.Request) (reconc } case common.StatusResourceCreated: // Import / update dashboard - return r.importDashboard(cr) + res, err := r.importDashboard(cr) + + // Requeue periodically to find dashboards that have not been updated + // but are not yet imported (can happen if Grafana is uninstalled and + // then reinstalled without an Operator restart + res.RequeueAfter = common.RequeueDelay + return res, err default: return reconcile.Result{}, nil } @@ -242,7 +248,6 @@ func (r *ReconcileGrafanaDashboard) isJsonValid(cr *i8ly.GrafanaDashboard) (bool var js map[string]interface{} err := json.Unmarshal([]byte(cr.Spec.Json), &js) return err == nil, err - } func (r *ReconcileGrafanaDashboard) hasDashboardChanged(cr *i8ly.GrafanaDashboard) (bool, string) { diff --git a/pkg/controller/grafanadatasource/datasource_controller.go b/pkg/controller/grafanadatasource/datasource_controller.go index 7ab67cd19..5712ff5d8 100644 --- a/pkg/controller/grafanadatasource/datasource_controller.go +++ b/pkg/controller/grafanadatasource/datasource_controller.go @@ -105,7 +105,13 @@ func (r *ReconcileGrafanaDataSource) Reconcile(request reconcile.Request) (recon return r.setFinalizer(cr) } case common.StatusResourceCreated: - return r.reconcileDatasource(cr) + res, err := r.reconcileDatasource(cr) + + // Requeue periodically to find datasources that have not been updated + // but are not yet imported (can happen if Grafana is uninstalled and + // then reinstalled without an Operator restart + res.RequeueAfter = common.RequeueDelay + return res, err default: return reconcile.Result{}, nil }