Skip to content

Commit 9321239

Browse files
authored
Only update LastResync if it has expired (#1110)
* Only update LastResync if it has expired Solves #1109
1 parent 91d73f2 commit 9321239

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

controllers/dashboard_controller.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,10 @@ func (r *GrafanaDashboardReconciler) Reconcile(ctx context.Context, req ctrl.Req
256256

257257
// if the dashboard was successfully synced in all instances, wait for its re-sync period
258258
if success {
259+
if cr.ResyncPeriodHasElapsed() {
260+
cr.Status.LastResync = metav1.Time{Time: time.Now()}
261+
}
259262
cr.Status.Hash = hash
260-
cr.Status.LastResync = metav1.Time{Time: time.Now()}
261263
cr.Status.UID = uid
262264
return ctrl.Result{RequeueAfter: cr.GetResyncPeriod()}, r.Client.Status().Update(ctx, cr)
263265
}

controllers/datasource_controller.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,9 @@ func (r *GrafanaDatasourceReconciler) Reconcile(ctx context.Context, req ctrl.Re
250250
if success {
251251
cr.Status.LastMessage = ""
252252
cr.Status.Hash = hash
253-
cr.Status.LastResync = metav1.Time{Time: time.Now()}
253+
if cr.ResyncPeriodHasElapsed() {
254+
cr.Status.LastResync = metav1.Time{Time: time.Now()}
255+
}
254256
cr.Status.UID = datasource.UID
255257
return ctrl.Result{RequeueAfter: cr.GetResyncPeriod()}, r.Client.Status().Update(ctx, cr)
256258
} else {

0 commit comments

Comments
 (0)