Skip to content

Commit f109634

Browse files
committed
migrate from Requeue to RequeueAfter in kcp
Signed-off-by: sivchari <[email protected]>
1 parent 4fe9364 commit f109634

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

controlplane/kubeadm/internal/controllers/controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func (r *KubeadmControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.
212212
patchHelper, err := patch.NewHelper(kcp, r.Client)
213213
if err != nil {
214214
log.Error(err, "Failed to configure the patch helper")
215-
return ctrl.Result{Requeue: true}, nil
215+
return ctrl.Result{RequeueAfter: 20 * time.Second}, nil
216216
}
217217

218218
if isPaused, requeue, err := paused.EnsurePausedCondition(ctx, r.Client, cluster, kcp); err != nil || isPaused || requeue {
@@ -559,7 +559,7 @@ func (r *KubeadmControlPlaneReconciler) reconcile(ctx context.Context, controlPl
559559
workloadCluster, err := controlPlane.GetWorkloadCluster(ctx)
560560
if err != nil {
561561
log.V(2).Info("cannot get remote client to workload cluster, will requeue", "cause", err)
562-
return ctrl.Result{Requeue: true}, nil
562+
return ctrl.Result{RequeueAfter: 20 * time.Second}, nil
563563
}
564564

565565
// Update kube-proxy daemonset.

controlplane/kubeadm/internal/controllers/controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ func TestReconcileClusterNoEndpoints(t *testing.T) {
488488
result, err = r.Reconcile(ctx, ctrl.Request{NamespacedName: util.ObjectKey(kcp)})
489489
g.Expect(err).ToNot(HaveOccurred())
490490
// TODO: this should stop to re-queue as soon as we have a proper remote cluster cache in place.
491-
g.Expect(result).To(BeComparableTo(ctrl.Result{Requeue: false, RequeueAfter: 20 * time.Second}))
491+
g.Expect(result.RequeueAfter).To(Equal(20 * time.Second))
492492
g.Expect(r.Client.Get(ctx, util.ObjectKey(kcp), kcp)).To(Succeed())
493493

494494
// Always expect that the Finalizer is set on the passed in resource

controlplane/kubeadm/internal/controllers/remediation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ func (r *KubeadmControlPlaneReconciler) reconcileUnhealthyMachines(ctx context.C
368368
controlplanev1.RemediationInProgressAnnotation: remediationInProgressValue,
369369
})
370370

371-
return ctrl.Result{Requeue: true}, nil
371+
return ctrl.Result{RequeueAfter: 20 * time.Second}, nil
372372
}
373373

374374
// Gets the machine to be remediated, which is the "most broken" among the unhealthy machines, determined as the machine

controlplane/kubeadm/internal/controllers/scale.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (r *KubeadmControlPlaneReconciler) initializeControlPlane(ctx context.Conte
6060
newMachine.Spec.Bootstrap.ConfigRef.Kind, klog.KRef(newMachine.Namespace, newMachine.Spec.Bootstrap.ConfigRef.Name))
6161

6262
// Requeue the control plane, in case there are additional operations to perform
63-
return ctrl.Result{Requeue: true}, nil
63+
return ctrl.Result{RequeueAfter: 20 * time.Second}, nil
6464
}
6565

6666
func (r *KubeadmControlPlaneReconciler) scaleUpControlPlane(ctx context.Context, controlPlane *internal.ControlPlane) (ctrl.Result, error) {
@@ -94,7 +94,7 @@ func (r *KubeadmControlPlaneReconciler) scaleUpControlPlane(ctx context.Context,
9494
newMachine.Spec.Bootstrap.ConfigRef.Kind, klog.KRef(newMachine.Namespace, newMachine.Spec.Bootstrap.ConfigRef.Name))
9595

9696
// Requeue the control plane, in case there are other operations to perform
97-
return ctrl.Result{Requeue: true}, nil
97+
return ctrl.Result{RequeueAfter: 20 * time.Second}, nil
9898
}
9999

100100
func (r *KubeadmControlPlaneReconciler) scaleDownControlPlane(
@@ -148,7 +148,7 @@ func (r *KubeadmControlPlaneReconciler) scaleDownControlPlane(
148148
Info(fmt.Sprintf("Machine %s deleting (scale down)", machineToDelete.Name), "Machine", klog.KObj(machineToDelete))
149149

150150
// Requeue the control plane, in case there are additional operations to perform
151-
return ctrl.Result{Requeue: true}, nil
151+
return ctrl.Result{RequeueAfter: 20 * time.Second}, nil
152152
}
153153

154154
// preflightChecks checks if the control plane is stable before proceeding with a scale up/scale down operation,

controlplane/kubeadm/internal/controllers/scale_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func TestKubeadmControlPlaneReconciler_initializeControlPlane(t *testing.T) {
8484
}
8585

8686
result, err := r.initializeControlPlane(ctx, controlPlane)
87-
g.Expect(result).To(BeComparableTo(ctrl.Result{Requeue: true}))
87+
g.Expect(result.RequeueAfter).To(Equal(20 * time.Second))
8888
g.Expect(err).ToNot(HaveOccurred())
8989

9090
machineList := &clusterv1.MachineList{}
@@ -164,7 +164,7 @@ func TestKubeadmControlPlaneReconciler_scaleUpControlPlane(t *testing.T) {
164164
}
165165

166166
result, err := r.scaleUpControlPlane(ctx, controlPlane)
167-
g.Expect(result).To(BeComparableTo(ctrl.Result{Requeue: true}))
167+
g.Expect(result.RequeueAfter).To(Equal(20 * time.Second))
168168
g.Expect(err).ToNot(HaveOccurred())
169169

170170
controlPlaneMachines := clusterv1.MachineList{}
@@ -297,7 +297,7 @@ func TestKubeadmControlPlaneReconciler_scaleDownControlPlane_NoError(t *testing.
297297
g.Expect(err).ToNot(HaveOccurred())
298298
result, err := r.scaleDownControlPlane(context.Background(), controlPlane, machineToDelete)
299299
g.Expect(err).ToNot(HaveOccurred())
300-
g.Expect(result).To(BeComparableTo(ctrl.Result{Requeue: true}))
300+
g.Expect(result.RequeueAfter).To(Equal(20 * time.Second))
301301

302302
controlPlaneMachines := clusterv1.MachineList{}
303303
g.Expect(fakeClient.List(context.Background(), &controlPlaneMachines)).To(Succeed())
@@ -341,7 +341,7 @@ func TestKubeadmControlPlaneReconciler_scaleDownControlPlane_NoError(t *testing.
341341
g.Expect(err).ToNot(HaveOccurred())
342342
result, err := r.scaleDownControlPlane(context.Background(), controlPlane, machineToDelete)
343343
g.Expect(err).ToNot(HaveOccurred())
344-
g.Expect(result).To(BeComparableTo(ctrl.Result{Requeue: true}))
344+
g.Expect(result.RequeueAfter).To(Equal(20 * time.Second))
345345

346346
controlPlaneMachines := clusterv1.MachineList{}
347347
g.Expect(fakeClient.List(context.Background(), &controlPlaneMachines)).To(Succeed())

controlplane/kubeadm/internal/controllers/update_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func TestKubeadmControlPlaneReconciler_RolloutStrategy_ScaleUp(t *testing.T) {
116116
controlPlane.InjectTestManagementCluster(r.managementCluster)
117117

118118
result, err := r.initializeControlPlane(ctx, controlPlane)
119-
g.Expect(result).To(BeComparableTo(ctrl.Result{Requeue: true}))
119+
g.Expect(result.RequeueAfter).To(Equal(10 * time.Second))
120120
g.Expect(err).ToNot(HaveOccurred())
121121

122122
// initial setup
@@ -142,7 +142,7 @@ func TestKubeadmControlPlaneReconciler_RolloutStrategy_ScaleUp(t *testing.T) {
142142
machinesUpToDateResults[m.Name] = internal.UpToDateResult{EligibleForInPlaceUpdate: false}
143143
}
144144
result, err = r.updateControlPlane(ctx, controlPlane, needingUpgrade, machinesUpToDateResults)
145-
g.Expect(result).To(BeComparableTo(ctrl.Result{Requeue: true}))
145+
g.Expect(result.RequeueAfter).To(Equal(20 * time.Second))
146146
g.Expect(err).ToNot(HaveOccurred())
147147
bothMachines := &clusterv1.MachineList{}
148148
g.Eventually(func(g Gomega) {
@@ -193,7 +193,7 @@ func TestKubeadmControlPlaneReconciler_RolloutStrategy_ScaleUp(t *testing.T) {
193193
// run upgrade the second time, expect we scale down
194194
result, err = r.updateControlPlane(ctx, controlPlane, machinesRequireUpgrade, machinesUpToDateResults)
195195
g.Expect(err).ToNot(HaveOccurred())
196-
g.Expect(result).To(BeComparableTo(ctrl.Result{Requeue: true}))
196+
g.Expect(result.RequeueAfter).To(Equal(20 * time.Second))
197197
finalMachine := &clusterv1.MachineList{}
198198
g.Eventually(func(g Gomega) {
199199
g.Expect(env.List(ctx, finalMachine, client.InNamespace(cluster.Namespace))).To(Succeed())
@@ -287,7 +287,7 @@ func TestKubeadmControlPlaneReconciler_RolloutStrategy_ScaleDown(t *testing.T) {
287287
machinesUpToDateResults[m.Name] = internal.UpToDateResult{EligibleForInPlaceUpdate: false}
288288
}
289289
result, err = r.updateControlPlane(ctx, controlPlane, needingUpgrade, machinesUpToDateResults)
290-
g.Expect(result).To(BeComparableTo(ctrl.Result{Requeue: true}))
290+
g.Expect(result.RequeueAfter).To(Equal(20 * time.Second))
291291
g.Expect(err).ToNot(HaveOccurred())
292292
remainingMachines := &clusterv1.MachineList{}
293293
g.Expect(fakeClient.List(ctx, remainingMachines, client.InNamespace(cluster.Namespace))).To(Succeed())

0 commit comments

Comments
 (0)