Skip to content

Commit

Permalink
requeue KCP object if ControlPlaneComponentsHealthyCondition is not y…
Browse files Browse the repository at this point in the history
…et true
  • Loading branch information
chrischdi committed Jul 21, 2023
1 parent ddbf9cf commit bf812d8
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions controlplane/kubeadm/internal/controllers/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,22 @@ func (r *KubeadmControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.
reterr = kerrors.NewAggregate([]error{reterr, err})
}

// TODO: remove this as soon as we have a proper remote cluster cache in place.
// 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).
// 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.
if reterr == nil && !res.Requeue && res.RequeueAfter <= 0 && kcp.ObjectMeta.DeletionTimestamp.IsZero() {
if !kcp.Status.Ready {
if reterr == nil && kcp.ObjectMeta.DeletionTimestamp.IsZero() {
// TODO: remove this as soon as we have a proper remote cluster cache in place.
// 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).
// 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.
if !res.Requeue && res.RequeueAfter <= 0 {
if !kcp.Status.Ready {
res = ctrl.Result{RequeueAfter: 20 * time.Second}
}
}

// Make sure KCP gets requeued if ControlPlaneComponentsHealthyCondition is still false.
// Otherwise KCP would only get requeued when KCP or the Cluster gets a change or via reaching the resyncperiod.
// That would lead to a delay in provisioning MachineDeployments when preflight checks are enabled.
// The alternative solution to this requeue would be watching the relevant pods inside each workload
// cluster which would be very expensive.
if res.IsZero() && conditions.IsFalse(kcp, controlplanev1.ControlPlaneComponentsHealthyCondition) {
res = ctrl.Result{RequeueAfter: 20 * time.Second}
}
}
Expand Down

0 comments on commit bf812d8

Please sign in to comment.