Skip to content

Commit

Permalink
Only update LastResync if it has expired (#1110)
Browse files Browse the repository at this point in the history
* Only update LastResync if it has expired

Solves #1109
  • Loading branch information
NissesSenap authored Jun 16, 2023
1 parent 91d73f2 commit 9321239
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion controllers/dashboard_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 3 additions & 1 deletion controllers/datasource_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9321239

Please sign in to comment.