Skip to content

Commit 4dd60f5

Browse files
authored
Merge pull request #9032 from chrischdi/pr-kcp-requeue-condition-components
🐛 requeue KCP object if ControlPlaneComponentsHealthyCondition is not yet true
2 parents de0ed1e + 205a1f5 commit 4dd60f5

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

controlplane/kubeadm/internal/controllers/controller.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,23 @@ func (r *KubeadmControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.
222222
reterr = kerrors.NewAggregate([]error{reterr, err})
223223
}
224224

225-
// TODO: remove this as soon as we have a proper remote cluster cache in place.
226-
// Make KCP to requeue in case status is not ready, so we can check for node status without waiting for a full resync (by default 10 minutes).
227-
// Only requeue if we are not going in exponential backoff due to error, or if we are not already re-queueing, or if the object has a deletion timestamp.
228-
if reterr == nil && !res.Requeue && res.RequeueAfter <= 0 && kcp.ObjectMeta.DeletionTimestamp.IsZero() {
225+
// Only requeue if there is no error, Requeue or RequeueAfter and the object does not have a deletion timestamp.
226+
if reterr == nil && res.IsZero() && kcp.ObjectMeta.DeletionTimestamp.IsZero() {
227+
// Make KCP requeue in case node status is not ready, so we can check for node status without waiting for a full
228+
// resync (by default 10 minutes).
229+
// The alternative solution would be to watch the control plane nodes in the Cluster - similar to how the
230+
// MachineSet and MachineHealthCheck controllers watch the nodes under their control.
229231
if !kcp.Status.Ready {
230232
res = ctrl.Result{RequeueAfter: 20 * time.Second}
231233
}
234+
235+
// Make KCP requeue if ControlPlaneComponentsHealthyCondition is false so we can check for control plane component
236+
// status without waiting for a full resync (by default 10 minutes).
237+
// Otherwise this condition can lead to a delay in provisioning MachineDeployments when MachineSet preflight checks are enabled.
238+
// The alternative solution to this requeue would be watching the relevant pods inside each workload cluster which would be very expensive.
239+
if conditions.IsFalse(kcp, controlplanev1.ControlPlaneComponentsHealthyCondition) {
240+
res = ctrl.Result{RequeueAfter: 20 * time.Second}
241+
}
232242
}
233243
}()
234244

0 commit comments

Comments
 (0)