Skip to content

Commit

Permalink
perf: requeue KeptnMetric and process them only when deadline is met (
Browse files Browse the repository at this point in the history
  • Loading branch information
thisthat committed Jan 25, 2023
1 parent 9d9a07c commit 39dd3f8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion operator/controllers/metrics/keptnmetric_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ func (r *KeptnMetricReconciler) Reconcile(ctx context.Context, req ctrl.Request)

fetchTime := metric.Status.LastUpdated.Add(time.Second * time.Duration(metric.Spec.FetchIntervalSeconds))
if time.Now().Before(fetchTime) {
diff := time.Until(fetchTime)
r.Log.Info("Metric has not been updated for the configured interval. Skipping")
return ctrl.Result{Requeue: true, RequeueAfter: 10 * time.Second}, nil
return ctrl.Result{Requeue: true, RequeueAfter: diff}, nil
}

evaluationProvider, err := r.fetchProvider(ctx, types.NamespacedName{Name: metric.Spec.Provider.Name, Namespace: metric.Namespace})
Expand Down

0 comments on commit 39dd3f8

Please sign in to comment.