From 9321239f12761b4a74ff51f4cbc0043ee7e6351b Mon Sep 17 00:00:00 2001 From: Edvin N Date: Fri, 16 Jun 2023 15:00:54 +0200 Subject: [PATCH] Only update LastResync if it has expired (#1110) * Only update LastResync if it has expired Solves #1109 --- controllers/dashboard_controller.go | 4 +++- controllers/datasource_controller.go | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/controllers/dashboard_controller.go b/controllers/dashboard_controller.go index 2bca69091..18e1f2f3d 100644 --- a/controllers/dashboard_controller.go +++ b/controllers/dashboard_controller.go @@ -256,8 +256,10 @@ func (r *GrafanaDashboardReconciler) Reconcile(ctx context.Context, req ctrl.Req // if the dashboard was successfully synced in all instances, wait for its re-sync period if success { + if cr.ResyncPeriodHasElapsed() { + cr.Status.LastResync = metav1.Time{Time: time.Now()} + } cr.Status.Hash = hash - cr.Status.LastResync = metav1.Time{Time: time.Now()} cr.Status.UID = uid return ctrl.Result{RequeueAfter: cr.GetResyncPeriod()}, r.Client.Status().Update(ctx, cr) } diff --git a/controllers/datasource_controller.go b/controllers/datasource_controller.go index 9f27206b5..e4ad23bf3 100644 --- a/controllers/datasource_controller.go +++ b/controllers/datasource_controller.go @@ -250,7 +250,9 @@ func (r *GrafanaDatasourceReconciler) Reconcile(ctx context.Context, req ctrl.Re if success { cr.Status.LastMessage = "" cr.Status.Hash = hash - cr.Status.LastResync = metav1.Time{Time: time.Now()} + if cr.ResyncPeriodHasElapsed() { + cr.Status.LastResync = metav1.Time{Time: time.Now()} + } cr.Status.UID = datasource.UID return ctrl.Result{RequeueAfter: cr.GetResyncPeriod()}, r.Client.Status().Update(ctx, cr) } else {