Skip to content

Commit

Permalink
Merge pull request #11436 from sbueringer/pr-rate-limit-reconcile-delete
Browse files Browse the repository at this point in the history
🌱 Rate-limit entire reconcileDelete
  • Loading branch information
k8s-ci-robot authored Nov 19, 2024
2 parents ac61652 + 809e290 commit 0a52420
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions internal/controllers/machine/machine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,16 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Re
return ctrl.Result{}, err
}

if !m.ObjectMeta.DeletionTimestamp.IsZero() {
// Check reconcileDeleteCache to ensure we won't run reconcileDelete too frequently.
// Note: The reconcileDelete func will add entries to the cache.
if cacheEntry, ok := r.reconcileDeleteCache.Has(cache.NewReconcileEntryKey(m)); ok {
if requeueAfter, requeue := cacheEntry.ShouldRequeue(time.Now()); requeue {
return ctrl.Result{RequeueAfter: requeueAfter}, nil
}
}
}

s := &scope{
cluster: cluster,
machine: m,
Expand Down Expand Up @@ -418,13 +428,6 @@ func (r *Reconciler) reconcileDelete(ctx context.Context, s *scope) (ctrl.Result
cluster := s.cluster
m := s.machine

// Check reconcileDeleteCache to ensure we won't run reconcileDelete too frequently.
if cacheEntry, ok := r.reconcileDeleteCache.Has(cache.NewReconcileEntryKey(s.machine)); ok {
if requeueAfter, requeue := cacheEntry.ShouldRequeue(time.Now()); requeue {
return ctrl.Result{RequeueAfter: requeueAfter}, nil
}
}

s.reconcileDeleteExecuted = true

// Add entry to the reconcileDeleteCache so we won't run reconcileDelete more than once per second.
Expand Down

0 comments on commit 0a52420

Please sign in to comment.