Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions controlplane/kubeadm/controllers/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package controllers

import (
"context"
"k8s.io/apimachinery/pkg/util/intstr"

"github.com/blang/semver"
"github.com/pkg/errors"
Expand Down Expand Up @@ -110,6 +111,20 @@ func (r *KubeadmControlPlaneReconciler) upgradeControlPlane(
return ctrl.Result{}, errors.Wrap(err, "failed to upgrade kubelet config map")
}

// this should be already handled by the defaulting webhook, but during rolling upgrade it is possible that

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we still need this.
This was for the CAPI upgrade when RolloutStrategy was introduced, the clusters created before that upgrade does not have the strategy, so we need to make sure after that upgrade the strategy should be set.
For all the clusters we have right now, they should already have this set, so probably don't need this change.

// kcp version got updated first before the webhook pod update, then the new kcp does not have the default value
// then later on when webhook pod updated, kcp.spec have no updates, so the value not set and controller will have nil pointer
// so do a quick hack here to set the default if it's empty
if kcp.Spec.RolloutStrategy == nil {
ios1 := intstr.FromInt(1)
kcp.Spec.RolloutStrategy = &controlplanev1.RolloutStrategy{
Type: controlplanev1.RollingUpdateStrategyType,
RollingUpdate: &controlplanev1.RollingUpdate{
MaxSurge: &ios1,
},
}
}

switch kcp.Spec.RolloutStrategy.Type {
case controlplanev1.RollingUpdateStrategyType:
// RolloutStrategy is currently defaulted and validated to be RollingUpdate
Expand Down