From c437b3b115ac82acf10c101319052c1b2973ccdb Mon Sep 17 00:00:00 2001 From: jan-est Date: Thu, 25 Mar 2021 10:43:57 +0200 Subject: [PATCH] Fix issue comment 4293 status.Nodes is not the resource status. Method which is populating this field is using the cached client, which is not ideal when taking decision about scale up or down. This PR change KCP to use list of machines in the controlPlane object for making scaling decision. --- controlplane/kubeadm/controllers/upgrade.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/controlplane/kubeadm/controllers/upgrade.go b/controlplane/kubeadm/controllers/upgrade.go index 81d477de2f4b..55be6292baf0 100644 --- a/controlplane/kubeadm/controllers/upgrade.go +++ b/controlplane/kubeadm/controllers/upgrade.go @@ -105,17 +105,12 @@ func (r *KubeadmControlPlaneReconciler) upgradeControlPlane( return ctrl.Result{}, errors.Wrap(err, "failed to upgrade kubelet config map") } - status, err := workloadCluster.ClusterStatus(ctx) - if err != nil { - return ctrl.Result{}, err - } - switch kcp.Spec.RolloutStrategy.Type { case controlplanev1.RollingUpdateStrategyType: // RolloutStrategy is currently defaulted and validated to be RollingUpdate // We can ignore MaxUnavailable because we are enforcing health checks before we get here. maxNodes := *kcp.Spec.Replicas + int32(kcp.Spec.RolloutStrategy.RollingUpdate.MaxSurge.IntValue()) - if status.Nodes < maxNodes { + if int32(controlPlane.Machines.Len()) < maxNodes { // scaleUp ensures that we don't continue scaling up while waiting for Machines to have NodeRefs return r.scaleUpControlPlane(ctx, cluster, kcp, controlPlane) }