-
Notifications
You must be signed in to change notification settings - Fork 1.4k
🌱 Migrate from Requeue to RequeueAfter in kcp #13028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -212,7 +212,7 @@ func (r *KubeadmControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl. | |
| patchHelper, err := patch.NewHelper(kcp, r.Client) | ||
| if err != nil { | ||
| log.Error(err, "Failed to configure the patch helper") | ||
| return ctrl.Result{Requeue: true}, nil | ||
| return ctrl.Result{RequeueAfter: 20 * time.Second}, nil | ||
| } | ||
|
|
||
| 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 | |
| workloadCluster, err := controlPlane.GetWorkloadCluster(ctx) | ||
| if err != nil { | ||
| log.V(2).Info("cannot get remote client to workload cluster, will requeue", "cause", err) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, let's just drop the log and return the error directly (and use an empty result) |
||
| return ctrl.Result{Requeue: true}, nil | ||
| return ctrl.Result{RequeueAfter: 20 * time.Second}, nil | ||
| } | ||
|
|
||
| // Update kube-proxy daemonset. | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -368,7 +368,7 @@ func (r *KubeadmControlPlaneReconciler) reconcileUnhealthyMachines(ctx context.C | |||||
| controlplanev1.RemediationInProgressAnnotation: remediationInProgressValue, | ||||||
| }) | ||||||
|
|
||||||
| return ctrl.Result{Requeue: true}, nil | ||||||
| return ctrl.Result{RequeueAfter: 20 * time.Second}, nil | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| } | ||||||
|
|
||||||
| // Gets the machine to be remediated, which is the "most broken" among the unhealthy machines, determined as the machine | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -60,7 +60,7 @@ func (r *KubeadmControlPlaneReconciler) initializeControlPlane(ctx context.Conte | |||||
| newMachine.Spec.Bootstrap.ConfigRef.Kind, klog.KRef(newMachine.Namespace, newMachine.Spec.Bootstrap.ConfigRef.Name)) | ||||||
|
|
||||||
| // Requeue the control plane, in case there are additional operations to perform | ||||||
| return ctrl.Result{Requeue: true}, nil | ||||||
| return ctrl.Result{RequeueAfter: 20 * time.Second}, nil | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| } | ||||||
|
|
||||||
| func (r *KubeadmControlPlaneReconciler) scaleUpControlPlane(ctx context.Context, controlPlane *internal.ControlPlane) (ctrl.Result, error) { | ||||||
|
|
@@ -94,7 +94,7 @@ func (r *KubeadmControlPlaneReconciler) scaleUpControlPlane(ctx context.Context, | |||||
| newMachine.Spec.Bootstrap.ConfigRef.Kind, klog.KRef(newMachine.Namespace, newMachine.Spec.Bootstrap.ConfigRef.Name)) | ||||||
|
|
||||||
| // Requeue the control plane, in case there are other operations to perform | ||||||
| return ctrl.Result{Requeue: true}, nil | ||||||
| return ctrl.Result{RequeueAfter: 20 * time.Second}, nil | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| } | ||||||
|
|
||||||
| func (r *KubeadmControlPlaneReconciler) scaleDownControlPlane( | ||||||
|
|
@@ -148,7 +148,7 @@ func (r *KubeadmControlPlaneReconciler) scaleDownControlPlane( | |||||
| Info(fmt.Sprintf("Machine %s deleting (scale down)", machineToDelete.Name), "Machine", klog.KObj(machineToDelete)) | ||||||
|
|
||||||
| // Requeue the control plane, in case there are additional operations to perform | ||||||
| return ctrl.Result{Requeue: true}, nil | ||||||
| return ctrl.Result{RequeueAfter: 20 * time.Second}, nil | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| } | ||||||
|
|
||||||
| // preflightChecks checks if the control plane is stable before proceeding with a scale up/scale down operation, | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,7 +84,7 @@ func TestKubeadmControlPlaneReconciler_initializeControlPlane(t *testing.T) { | |
| } | ||
|
|
||
| result, err := r.initializeControlPlane(ctx, controlPlane) | ||
| g.Expect(result).To(BeComparableTo(ctrl.Result{Requeue: true})) | ||
| g.Expect(result.RequeueAfter).To(Equal(20 * time.Second)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please change the unit tests (also in other files) to check for result.IsZero to BeTrue() (where applicable) |
||
| g.Expect(err).ToNot(HaveOccurred()) | ||
|
|
||
| machineList := &clusterv1.MachineList{} | ||
|
|
@@ -164,7 +164,7 @@ func TestKubeadmControlPlaneReconciler_scaleUpControlPlane(t *testing.T) { | |
| } | ||
|
|
||
| result, err := r.scaleUpControlPlane(ctx, controlPlane) | ||
| g.Expect(result).To(BeComparableTo(ctrl.Result{Requeue: true})) | ||
| g.Expect(result.RequeueAfter).To(Equal(20 * time.Second)) | ||
| g.Expect(err).ToNot(HaveOccurred()) | ||
|
|
||
| controlPlaneMachines := clusterv1.MachineList{} | ||
|
|
@@ -297,7 +297,7 @@ func TestKubeadmControlPlaneReconciler_scaleDownControlPlane_NoError(t *testing. | |
| g.Expect(err).ToNot(HaveOccurred()) | ||
| result, err := r.scaleDownControlPlane(context.Background(), controlPlane, machineToDelete) | ||
| g.Expect(err).ToNot(HaveOccurred()) | ||
| g.Expect(result).To(BeComparableTo(ctrl.Result{Requeue: true})) | ||
| g.Expect(result.RequeueAfter).To(Equal(20 * time.Second)) | ||
|
|
||
| controlPlaneMachines := clusterv1.MachineList{} | ||
| g.Expect(fakeClient.List(context.Background(), &controlPlaneMachines)).To(Succeed()) | ||
|
|
@@ -341,7 +341,7 @@ func TestKubeadmControlPlaneReconciler_scaleDownControlPlane_NoError(t *testing. | |
| g.Expect(err).ToNot(HaveOccurred()) | ||
| result, err := r.scaleDownControlPlane(context.Background(), controlPlane, machineToDelete) | ||
| g.Expect(err).ToNot(HaveOccurred()) | ||
| g.Expect(result).To(BeComparableTo(ctrl.Result{Requeue: true})) | ||
| g.Expect(result.RequeueAfter).To(Equal(20 * time.Second)) | ||
|
|
||
| controlPlaneMachines := clusterv1.MachineList{} | ||
| g.Expect(fakeClient.List(context.Background(), &controlPlaneMachines)).To(Succeed()) | ||
|
|
||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mix them without separating.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just intentionally added these in the PR merged yesterday. Please keep them (please see the godocs I explicitly added to the nolint statements) (please revert all changes to this file, this util will soon'ish also be used in other controller / repos. It has to handle Requeue appropriately and must have the corresponding unit test coverage for it) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should just be (this is pretty old code :))
(also drop the log in l.214)