Skip to content

Commit a271350

Browse files
authored
Merge pull request #1516 from justinsb/dont_use_requeue_in_controller_runtime
chore: don't use Requeue in controller-runtime
2 parents 5122c21 + 2dcd7ab commit a271350

File tree

5 files changed

+3
-21
lines changed

5 files changed

+3
-21
lines changed

controllers/gcpcluster_controller_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ var _ = Describe("GCPClusterReconciler", func() {
5555
})
5656
Expect(err).NotTo(HaveOccurred())
5757
Expect(result.RequeueAfter).To(BeZero())
58-
Expect(result.Requeue).To(BeFalse())
5958
})
6059
})
6160
})

controllers/gcpmachine_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ func (r *GCPMachineReconciler) reconcile(ctx context.Context, machineScope *scop
245245
default:
246246
machineScope.SetFailureReason("UpdateError")
247247
machineScope.SetFailureMessage(errors.Errorf("GCPMachine instance state %s is unexpected", instanceState))
248-
return ctrl.Result{Requeue: true}, nil
248+
return ctrl.Result{RequeueAfter: reconciler.DefaultRetryTime}, nil
249249
}
250250
}
251251

controllers/gcpmachine_controller_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ var _ = Describe("GCPMachineReconciler", func() {
4747
})
4848
Expect(err).NotTo(HaveOccurred())
4949
Expect(result.RequeueAfter).To(BeZero())
50-
Expect(result.Requeue).To(BeFalse())
5150
})
5251
})
5352
})

exp/controllers/gcpmanagedcontrolplane_controller.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (r *GCPManagedControlPlaneReconciler) Reconcile(ctx context.Context, req ct
9696
if apierrors.IsNotFound(err) {
9797
return ctrl.Result{}, nil
9898
}
99-
return ctrl.Result{Requeue: true}, nil
99+
return ctrl.Result{}, fmt.Errorf("getting GCPManagedControlPlane: %w", err)
100100
}
101101

102102
// Get the cluster
@@ -181,10 +181,6 @@ func (r *GCPManagedControlPlaneReconciler) reconcile(ctx context.Context, manage
181181
log.V(4).Info("Reconciler requested requeueAfter", "reconciler", name, "after", res.RequeueAfter)
182182
return res, nil
183183
}
184-
if res.Requeue {
185-
log.V(4).Info("Reconciler requested requeue", "reconciler", name)
186-
return res, nil
187-
}
188184
}
189185

190186
return ctrl.Result{}, nil
@@ -209,10 +205,6 @@ func (r *GCPManagedControlPlaneReconciler) reconcileDelete(ctx context.Context,
209205
log.V(4).Info("Reconciler requested requeueAfter", "reconciler", name, "after", res.RequeueAfter)
210206
return res, nil
211207
}
212-
if res.Requeue {
213-
log.V(4).Info("Reconciler requested requeue", "reconciler", name)
214-
return res, nil
215-
}
216208
}
217209

218210
if managedControlPlaneScope.GCPManagedControlPlane != nil &&

exp/controllers/gcpmanagedmachinepool_controller.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ func (r *GCPManagedMachinePoolReconciler) Reconcile(ctx context.Context, req ctr
237237
if apierrors.IsNotFound(err) {
238238
return ctrl.Result{}, nil
239239
}
240-
return ctrl.Result{Requeue: true}, nil
240+
return ctrl.Result{}, fmt.Errorf("getting GCPManagedMachinePool: %w", err)
241241
}
242242

243243
// Get the machine pool
@@ -354,10 +354,6 @@ func (r *GCPManagedMachinePoolReconciler) reconcile(ctx context.Context, managed
354354
log.V(4).Info("Reconciler requested requeueAfter", "reconciler", name, "after", res.RequeueAfter)
355355
return res, nil
356356
}
357-
if res.Requeue {
358-
log.V(4).Info("Reconciler requested requeue", "reconciler", name)
359-
return res, nil
360-
}
361357
}
362358

363359
return ctrl.Result{}, nil
@@ -390,10 +386,6 @@ func (r *GCPManagedMachinePoolReconciler) reconcileDelete(ctx context.Context, m
390386
log.V(4).Info("Reconciler requested requeueAfter", "reconciler", name, "after", res.RequeueAfter)
391387
return res, nil
392388
}
393-
if res.Requeue {
394-
log.V(4).Info("Reconciler requested requeue", "reconciler", name)
395-
return res, nil
396-
}
397389
}
398390

399391
if conditions.Get(managedMachinePoolScope.GCPManagedMachinePool, infrav1exp.GKEMachinePoolDeletingCondition).Reason == infrav1exp.GKEMachinePoolDeletedReason {

0 commit comments

Comments
 (0)