diff --git a/internal/pkg/api/cluster.go b/internal/pkg/api/cluster.go index f310d74bc46c5..1b40657a3fa33 100644 --- a/internal/pkg/api/cluster.go +++ b/internal/pkg/api/cluster.go @@ -351,25 +351,14 @@ func WithEtcdEncryptionFiller(kms *anywherev1.KMS, resources []string) ClusterFi func WithInPlaceUpgradeStrategy() ClusterFiller { return func(c *anywherev1.Cluster) { - if c.Spec.ControlPlaneConfiguration.UpgradeRolloutStrategy == nil { - c.Spec.ControlPlaneConfiguration.UpgradeRolloutStrategy = &anywherev1.ControlPlaneUpgradeRolloutStrategy{ - Type: anywherev1.InPlaceStrategyType, - } - } else { - c.Spec.ControlPlaneConfiguration.UpgradeRolloutStrategy = &anywherev1.ControlPlaneUpgradeRolloutStrategy{ - Type: anywherev1.InPlaceStrategyType, - } + c.Spec.ControlPlaneConfiguration.UpgradeRolloutStrategy = &anywherev1.ControlPlaneUpgradeRolloutStrategy{ + Type: anywherev1.InPlaceStrategyType, } - for _, wng := range c.Spec.WorkerNodeGroupConfigurations { - if wng.UpgradeRolloutStrategy == nil { - wng.UpgradeRolloutStrategy = &anywherev1.WorkerNodesUpgradeRolloutStrategy{ - Type: anywherev1.InPlaceStrategyType, - } - } else { - wng.UpgradeRolloutStrategy = &anywherev1.WorkerNodesUpgradeRolloutStrategy{ - Type: anywherev1.InPlaceStrategyType, - } + for idx, wng := range c.Spec.WorkerNodeGroupConfigurations { + wng.UpgradeRolloutStrategy = &anywherev1.WorkerNodesUpgradeRolloutStrategy{ + Type: anywherev1.InPlaceStrategyType, } + c.Spec.WorkerNodeGroupConfigurations[idx] = wng } } } diff --git a/test/e2e/tinkerbell_test.go b/test/e2e/tinkerbell_test.go index 1dab58e84f004..3112a7b382c2f 100644 --- a/test/e2e/tinkerbell_test.go +++ b/test/e2e/tinkerbell_test.go @@ -321,6 +321,50 @@ func TestTinkerbellKubernetes125UbuntuAddWorkerNodeGroupWithAPI(t *testing.T) { ) } +func TestTinkerbellKubernetes125UbuntuTo126InPlaceUpgrade(t *testing.T) { + provider := framework.NewTinkerbell(t) + kube125 := v1alpha1.Kube125 + test := framework.NewClusterE2ETest( + t, + provider, + framework.WithClusterFiller(api.WithKubernetesVersion(kube125)), + framework.WithClusterFiller(api.WithControlPlaneCount(1)), + framework.WithClusterFiller(api.WithWorkerNodeCount(1)), + framework.WithClusterFiller(api.WithInPlaceUpgradeStrategy()), + framework.WithControlPlaneHardware(1), + framework.WithWorkerHardware(1), + ).WithClusterConfig( + provider.WithKubeVersionAndOS(v1alpha1.Kube125, framework.Ubuntu2004, nil), + ) + runInPlaceUpgradeFlowForBareMetal( + test, + framework.WithClusterUpgrade(api.WithKubernetesVersion(v1alpha1.Kube126), api.WithInPlaceUpgradeStrategy()), + provider.WithProviderUpgrade(framework.Ubuntu126Image()), + ) +} + +func TestTinkerbellKubernetes126UbuntuTo127InPlaceUpgrade(t *testing.T) { + provider := framework.NewTinkerbell(t) + kube126 := v1alpha1.Kube126 + test := framework.NewClusterE2ETest( + t, + provider, + framework.WithClusterFiller(api.WithKubernetesVersion(kube126)), + framework.WithClusterFiller(api.WithControlPlaneCount(1)), + framework.WithClusterFiller(api.WithWorkerNodeCount(1)), + framework.WithClusterFiller(api.WithInPlaceUpgradeStrategy()), + framework.WithControlPlaneHardware(1), + framework.WithWorkerHardware(1), + ).WithClusterConfig( + provider.WithKubeVersionAndOS(v1alpha1.Kube126, framework.Ubuntu2004, nil), + ) + runInPlaceUpgradeFlowForBareMetal( + test, + framework.WithClusterUpgrade(api.WithKubernetesVersion(v1alpha1.Kube127), api.WithInPlaceUpgradeStrategy()), + provider.WithProviderUpgrade(framework.Ubuntu127Image()), + ) +} + func TestTinkerbellKubernetes127UbuntuTo128InPlaceUpgrade(t *testing.T) { provider := framework.NewTinkerbell(t) kube127 := v1alpha1.Kube127 @@ -330,7 +374,7 @@ func TestTinkerbellKubernetes127UbuntuTo128InPlaceUpgrade(t *testing.T) { framework.WithClusterFiller(api.WithKubernetesVersion(kube127)), framework.WithClusterFiller(api.WithControlPlaneCount(1)), framework.WithClusterFiller(api.WithWorkerNodeCount(1)), - framework.WithClusterFiller(api.WithWorkerKubernetesVersion(nodeGroupLabel1, &kube127)), + framework.WithClusterFiller(api.WithInPlaceUpgradeStrategy()), framework.WithControlPlaneHardware(1), framework.WithWorkerHardware(1), ).WithClusterConfig( @@ -338,7 +382,7 @@ func TestTinkerbellKubernetes127UbuntuTo128InPlaceUpgrade(t *testing.T) { ) runInPlaceUpgradeFlowForBareMetal( test, - framework.WithClusterUpgrade(api.WithKubernetesVersion(v1alpha1.Kube128)), + framework.WithClusterUpgrade(api.WithKubernetesVersion(v1alpha1.Kube128), api.WithInPlaceUpgradeStrategy()), provider.WithProviderUpgrade(framework.Ubuntu128Image()), ) }