Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 9 additions & 1 deletion api/controlplane/kubeadm/v1beta1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,15 @@ func Convert_v1beta1_KubeadmControlPlaneTemplateResourceSpec_To_v1beta2_KubeadmC
out.Rollout.After = *in.RolloutAfter
}
if in.RolloutStrategy != nil {
out.Rollout.Strategy.Type = controlplanev1.KubeadmControlPlaneRolloutStrategyType(in.RolloutStrategy.Type)
// If Type is empty in v1beta1, set it to RollingUpdateStrategyType.
// This is the same behavior as in previous versions of Cluster API as Type
// was always defaulted to RollingUpdateStrategyType, and also RollingUpdateStrategyType
// is the only valid value.
if in.RolloutStrategy.Type == "" {
out.Rollout.Strategy.Type = controlplanev1.RollingUpdateStrategyType
} else {
out.Rollout.Strategy.Type = controlplanev1.KubeadmControlPlaneRolloutStrategyType(in.RolloutStrategy.Type)
}
if in.RolloutStrategy.RollingUpdate != nil && in.RolloutStrategy.RollingUpdate.MaxSurge != nil {
out.Rollout.Strategy.RollingUpdate.MaxSurge = in.RolloutStrategy.RollingUpdate.MaxSurge
}
Expand Down
17 changes: 17 additions & 0 deletions api/controlplane/kubeadm/v1beta1/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func KubeadmControlPlaneTemplateFuzzFuncs(_ runtimeserializer.CodecFactory) []in
spokeDiscovery,
hubKubeadmConfigSpec,
hubNodeRegistrationOptions,
hubKubeadmControlPlaneTemplate,
spokeKubeadmControlPlaneTemplate,
spokeRemediationStrategy,
spokeKubeadmControlPlaneTemplateMachineTemplate,
Expand Down Expand Up @@ -364,6 +365,15 @@ func spokeClusterConfiguration(in *bootstrapv1beta1.ClusterConfiguration, c rand
}
}

func hubKubeadmControlPlaneTemplate(in *controlplanev1.KubeadmControlPlaneTemplate, c randfill.Continue) {
c.FillNoCustom(in)

// In v1beta2 Type is required and RollingUpdateStrategyType is the only valid value.
if in.Spec.Template.Spec.Rollout.Strategy.Type == "" {
in.Spec.Template.Spec.Rollout.Strategy.Type = controlplanev1.RollingUpdateStrategyType
}
}

func spokeKubeadmControlPlaneTemplate(in *KubeadmControlPlaneTemplate, c randfill.Continue) {
c.FillNoCustom(in)

Expand All @@ -384,6 +394,13 @@ func spokeKubeadmControlPlaneTemplate(in *KubeadmControlPlaneTemplate, c randfil
if reflect.DeepEqual(in.Spec.Template.Spec.MachineNamingStrategy, &MachineNamingStrategy{}) {
in.Spec.Template.Spec.MachineNamingStrategy = nil
}

// In v1beta1 Type was always defaulted to RollingUpdateStrategyType.
// RollingUpdateStrategyType is also the only valid value.
if in.Spec.Template.Spec.RolloutStrategy != nil &&
in.Spec.Template.Spec.RolloutStrategy.Type == "" {
in.Spec.Template.Spec.RolloutStrategy.Type = RollingUpdateStrategyType
}
}

func spokeRemediationStrategy(in *RemediationStrategy, c randfill.Continue) {
Expand Down