diff --git a/pkg/providers/cloudstack/cloudstack.go b/pkg/providers/cloudstack/cloudstack.go index ebe124f145ec6..a8573a1836751 100644 --- a/pkg/providers/cloudstack/cloudstack.go +++ b/pkg/providers/cloudstack/cloudstack.go @@ -428,6 +428,15 @@ func (p *cloudstackProvider) SetupAndValidateDeleteCluster(ctx context.Context, return nil } +// SetupAndValidateUpgradeManagementComponents performs necessary setup for upgrade management components operation. +func (p *cloudstackProvider) SetupAndValidateUpgradeManagementComponents(ctx context.Context, _ *cluster.Spec) error { + err := p.validateEnv(ctx) + if err != nil { + return fmt.Errorf("validating environment variables: %v", err) + } + return nil +} + func needsNewControlPlaneTemplate(oldSpec, newSpec *cluster.Spec, oldCsmc, newCsmc *v1alpha1.CloudStackMachineConfig, log logr.Logger) bool { // Another option is to generate MachineTemplates based on the old and new eksa spec, // remove the name field and compare them with DeepEqual diff --git a/pkg/providers/docker/docker.go b/pkg/providers/docker/docker.go index d93471ea3fe5c..d3778f7f2d6f7 100644 --- a/pkg/providers/docker/docker.go +++ b/pkg/providers/docker/docker.go @@ -172,6 +172,11 @@ func (p *Provider) SetupAndValidateUpgradeCluster(ctx context.Context, _ *types. return nil } +// SetupAndValidateUpgradeManagementComponents performs necessary setup for upgrade management components operation. +func (p *Provider) SetupAndValidateUpgradeManagementComponents(_ context.Context, _ *cluster.Spec) error { + return nil +} + // UpdateSecrets is a no-op. It implements providers.Provider. func (p *Provider) UpdateSecrets(ctx context.Context, cluster *types.Cluster, _ *cluster.Spec) error { // Not implemented diff --git a/pkg/providers/mocks/providers.go b/pkg/providers/mocks/providers.go index fdcb66896eb3d..bb88d9f911d10 100644 --- a/pkg/providers/mocks/providers.go +++ b/pkg/providers/mocks/providers.go @@ -409,6 +409,20 @@ func (mr *MockProviderMockRecorder) SetupAndValidateUpgradeCluster(arg0, arg1, a return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetupAndValidateUpgradeCluster", reflect.TypeOf((*MockProvider)(nil).SetupAndValidateUpgradeCluster), arg0, arg1, arg2, arg3) } +// SetupAndValidateUpgradeManagementComponents mocks base method. +func (m *MockProvider) SetupAndValidateUpgradeManagementComponents(arg0 context.Context, arg1 *cluster.Spec) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetupAndValidateUpgradeManagementComponents", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetupAndValidateUpgradeManagementComponents indicates an expected call of SetupAndValidateUpgradeManagementComponents. +func (mr *MockProviderMockRecorder) SetupAndValidateUpgradeManagementComponents(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetupAndValidateUpgradeManagementComponents", reflect.TypeOf((*MockProvider)(nil).SetupAndValidateUpgradeManagementComponents), arg0, arg1) +} + // UpdateKubeConfig mocks base method. func (m *MockProvider) UpdateKubeConfig(arg0 *[]byte, arg1 string) error { m.ctrl.T.Helper() diff --git a/pkg/providers/nutanix/provider.go b/pkg/providers/nutanix/provider.go index 9b3d31f7d76d5..1aafeadb52507 100644 --- a/pkg/providers/nutanix/provider.go +++ b/pkg/providers/nutanix/provider.go @@ -225,10 +225,20 @@ func (p *Provider) SetupAndValidateDeleteCluster(ctx context.Context, cluster *t // SetupAndValidateUpgradeCluster - Performs necessary setup and validations for upgrade cluster operation. func (p *Provider) SetupAndValidateUpgradeCluster(ctx context.Context, _ *types.Cluster, clusterSpec *cluster.Spec, _ *cluster.Spec) error { + // TODO(nutanix): Add validations when this is supported + if err := setupEnvVars(p.datacenterConfig); err != nil { + return fmt.Errorf("failed setup and validations: %v", err) + } + if err := p.validator.validateUpgradeRolloutStrategy(clusterSpec); err != nil { return fmt.Errorf("failed setup and validations: %v", err) } - // TODO(nutanix): Add validations when this is supported + + return nil +} + +// SetupAndValidateUpgradeManagementComponents performs necessary setup for upgrade management components operation. +func (p *Provider) SetupAndValidateUpgradeManagementComponents(_ context.Context, _ *cluster.Spec) error { if err := setupEnvVars(p.datacenterConfig); err != nil { return fmt.Errorf("failed setup and validations: %v", err) } diff --git a/pkg/providers/provider.go b/pkg/providers/provider.go index 12c0e29393454..958f08de27057 100644 --- a/pkg/providers/provider.go +++ b/pkg/providers/provider.go @@ -14,6 +14,7 @@ type Provider interface { SetupAndValidateCreateCluster(ctx context.Context, clusterSpec *cluster.Spec) error SetupAndValidateDeleteCluster(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec) error SetupAndValidateUpgradeCluster(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec, currentSpec *cluster.Spec) error + SetupAndValidateUpgradeManagementComponents(ctx context.Context, clusterSpec *cluster.Spec) error UpdateSecrets(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec) error GenerateCAPISpecForCreate(ctx context.Context, managementCluster *types.Cluster, clusterSpec *cluster.Spec) (controlPlaneSpec, workersSpec []byte, err error) GenerateCAPISpecForUpgrade(ctx context.Context, bootstrapCluster, workloadCluster *types.Cluster, currrentSpec, newClusterSpec *cluster.Spec) (controlPlaneSpec, workersSpec []byte, err error) diff --git a/pkg/providers/snow/snow.go b/pkg/providers/snow/snow.go index 402def0fb1e8d..f23cd80f800ce 100644 --- a/pkg/providers/snow/snow.go +++ b/pkg/providers/snow/snow.go @@ -90,6 +90,11 @@ func (p *SnowProvider) SetupAndValidateUpgradeCluster(ctx context.Context, clust return nil } +// SetupAndValidateUpgradeManagementComponents performs necessary setup for upgrade management components operation. +func (p *SnowProvider) SetupAndValidateUpgradeManagementComponents(_ context.Context, _ *cluster.Spec) error { + return nil +} + func (p *SnowProvider) SetupAndValidateDeleteCluster(ctx context.Context, _ *types.Cluster, clusterSpec *cluster.Spec) error { if err := SetupEksaCredentialsSecret(clusterSpec.Config); err != nil { return fmt.Errorf("setting up credentials: %v", err) diff --git a/pkg/providers/tinkerbell/upgrade.go b/pkg/providers/tinkerbell/upgrade.go index 069a3186212b2..5c4a171aeac07 100644 --- a/pkg/providers/tinkerbell/upgrade.go +++ b/pkg/providers/tinkerbell/upgrade.go @@ -146,6 +146,11 @@ func (p *Provider) SetupAndValidateUpgradeCluster(ctx context.Context, cluster * return nil } +// SetupAndValidateUpgradeManagementComponents performs necessary setup for upgrade management components operation. +func (p *Provider) SetupAndValidateUpgradeManagementComponents(_ context.Context, _ *cluster.Spec) error { + return nil +} + func (p *Provider) validateAvailableHardwareForUpgrade(ctx context.Context, currentSpec, newClusterSpec *cluster.Spec) (err error) { clusterSpecValidator := NewClusterSpecValidator( HardwareSatisfiesOnlyOneSelectorAssertion(p.catalogue), diff --git a/pkg/providers/vsphere/vsphere.go b/pkg/providers/vsphere/vsphere.go index 47e8b2b0666f1..7c0a330b92fc3 100644 --- a/pkg/providers/vsphere/vsphere.go +++ b/pkg/providers/vsphere/vsphere.go @@ -424,6 +424,15 @@ func (p *vsphereProvider) SetupAndValidateUpgradeCluster(ctx context.Context, cl return nil } +// SetupAndValidateUpgradeManagementComponents performs necessary setup for upgrade management components operation. +func (p *vsphereProvider) SetupAndValidateUpgradeManagementComponents(ctx context.Context, clusterSpec *cluster.Spec) error { + if err := SetupEnvVars(clusterSpec.VSphereDatacenter); err != nil { + return fmt.Errorf("failed environment variable setup: %v", err) + } + + return nil +} + func (p *vsphereProvider) validateMachineConfigsNameUniqueness(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec) error { prevSpec, err := p.providerKubectlClient.GetEksaCluster(ctx, cluster, clusterSpec.Cluster.GetName()) if err != nil { diff --git a/pkg/workflows/management/upgrade_management_components.go b/pkg/workflows/management/upgrade_management_components.go index ea99eb25b0512..1993278c278a8 100644 --- a/pkg/workflows/management/upgrade_management_components.go +++ b/pkg/workflows/management/upgrade_management_components.go @@ -122,8 +122,8 @@ func (s *setupAndValidateMC) Run(ctx context.Context, commandContext *task.Comma runner.Register( func() *validations.ValidationResult { return &validations.ValidationResult{ - Name: fmt.Sprintf("%s provider validation", commandContext.Provider.Name()), - Err: commandContext.Provider.SetupAndValidateUpgradeCluster(ctx, commandContext.ManagementCluster, commandContext.ClusterSpec, commandContext.CurrentClusterSpec), + Name: fmt.Sprintf("%s provider setup and validation", commandContext.Provider.Name()), + Err: commandContext.Provider.SetupAndValidateUpgradeManagementComponents(ctx, commandContext.ClusterSpec), } }, ) diff --git a/pkg/workflows/management/upgrade_management_components_test.go b/pkg/workflows/management/upgrade_management_components_test.go index 33932bc794d7d..251ccde9580a8 100644 --- a/pkg/workflows/management/upgrade_management_components_test.go +++ b/pkg/workflows/management/upgrade_management_components_test.go @@ -108,7 +108,7 @@ func TestRunnerHappyPath(t *testing.T) { gomock.InOrder( mocks.validator.EXPECT().PreflightValidations(ctx).Return(nil), mocks.provider.EXPECT().Name(), - mocks.provider.EXPECT().SetupAndValidateUpgradeCluster(ctx, gomock.Any(), newSpec, curSpec), + mocks.provider.EXPECT().SetupAndValidateUpgradeManagementComponents(ctx, newSpec), mocks.provider.EXPECT().PreCoreComponentsUpgrade(gomock.Any(), gomock.Any(), newManagementComponents, gomock.Any()), mocks.clientFactory.EXPECT().BuildClientFromKubeconfig(managementCluster.KubeconfigFile).Return(client, nil), mocks.capiManager.EXPECT().Upgrade(ctx, managementCluster, mocks.provider, currentManagementComponents, newManagementComponents, newSpec).Return(capiChangeDiff, nil), @@ -160,7 +160,7 @@ func TestRunnerStopsWhenValidationFailed(t *testing.T) { newSpec := test.NewClusterSpec() mocks.provider.EXPECT().Name() - mocks.provider.EXPECT().SetupAndValidateUpgradeCluster(ctx, gomock.Any(), newSpec, curSpec) + mocks.provider.EXPECT().SetupAndValidateUpgradeManagementComponents(ctx, newSpec) mocks.clusterManager.EXPECT().GetCurrentClusterSpec(ctx, gomock.Any(), managementCluster.Name).Return(curSpec, nil) mocks.validator.EXPECT().PreflightValidations(ctx).Return( []validations.Validation{ diff --git a/test/e2e/cloudstack_test.go b/test/e2e/cloudstack_test.go index 1328b1b172de9..93662c3aa6021 100644 --- a/test/e2e/cloudstack_test.go +++ b/test/e2e/cloudstack_test.go @@ -977,6 +977,12 @@ func TestCloudStackKubernetes129InstallGitFluxDuringUpgrade(t *testing.T) { ) } +func TestCloudStackKubernetes128UpgradeManagementComponents(t *testing.T) { + release := latestMinorRelease(t) + provider := framework.NewCloudStack(t, framework.WithCloudStackRedhat9Kubernetes128()) + runUpgradeManagementComponentsFlow(t, release, provider, v1alpha1.Kube128, framework.RedHat9) +} + // Labels func TestCloudStackKubernetes125LabelsAndNodeNameRedhat(t *testing.T) { test := framework.NewClusterE2ETest( diff --git a/test/e2e/docker_test.go b/test/e2e/docker_test.go index ac4b1f7905cce..f0c8623b749b8 100644 --- a/test/e2e/docker_test.go +++ b/test/e2e/docker_test.go @@ -1358,14 +1358,8 @@ func TestDockerKubernetesRegionalCuratedPackages(t *testing.T) { func TestDockerKubernetesUpgradeManagementComponents(t *testing.T) { release := latestMinorRelease(t) - test := framework.NewClusterE2ETest(t, framework.NewDocker(t)) - - test.GenerateClusterConfig() - // create cluster with old eksa - test.CreateCluster(framework.ExecuteWithEksaRelease(release)) - // upgrade management-components with new eksa - test.RunEKSA([]string{"upgrade", "management-components", "-f", test.ClusterConfigLocation, "-v", "99"}) - test.DeleteCluster() + provider := framework.NewDocker(t) + runUpgradeManagementComponentsFlow(t, release, provider, v1alpha1.Kube128, "") } // etcd scale tests diff --git a/test/e2e/tinkerbell_test.go b/test/e2e/tinkerbell_test.go index 26129f6f2c6f3..f182eb989644d 100644 --- a/test/e2e/tinkerbell_test.go +++ b/test/e2e/tinkerbell_test.go @@ -1478,3 +1478,30 @@ func TestTinkerbellSingleNode127To128UbuntuManagementCPUpgradeAPI(t *testing.T) provider.WithKubeVersionAndOS(v1alpha1.Kube128, framework.Ubuntu2004, nil), ) } + +func TestTinkerbellKubernetes128UpgradeManagementComponents(t *testing.T) { + release := latestMinorRelease(t) + provider := framework.NewTinkerbell(t, framework.WithUbuntu128Tinkerbell()) + test := framework.NewClusterE2ETest( + t, + provider, + framework.WithControlPlaneHardware(1), + framework.WithWorkerHardware(1), + ) + // create cluster with old eksa + test.GenerateClusterConfigForVersion(release.Version, framework.ExecuteWithEksaRelease(release)) + test.UpdateClusterConfig( + api.ClusterToConfigFiller( + api.WithKubernetesVersion(v1alpha1.Kube128), + api.WithControlPlaneCount(1), + api.WithWorkerNodeCount(1), + ), + provider.WithKubeVersionAndOS(v1alpha1.Kube128, framework.Ubuntu2004, nil), + ) + + test.GenerateHardwareConfig(framework.ExecuteWithEksaRelease(release)) + test.CreateCluster(framework.ExecuteWithEksaRelease(release), framework.WithControlPlaneWaitTimeout("20m")) + // upgrade management-components with new eksa + test.RunEKSA([]string{"upgrade", "management-components", "-f", test.ClusterConfigLocation, "-v", "99"}) + test.DeleteCluster() +} diff --git a/test/e2e/upgrade_from_latest.go b/test/e2e/upgrade_from_latest.go index d4daad4f23b86..4db97f39b740e 100644 --- a/test/e2e/upgrade_from_latest.go +++ b/test/e2e/upgrade_from_latest.go @@ -166,3 +166,22 @@ func runMulticlusterUpgradeFromReleaseFlowAPIWithFlux(test *framework.Multiclust test.DeleteManagementCluster() } + +func runUpgradeManagementComponentsFlow(t *testing.T, release *releasev1.EksARelease, provider framework.Provider, kubeVersion anywherev1.KubernetesVersion, os framework.OS) { + test := framework.NewClusterE2ETest(t, provider) + // create cluster with old eksa + test.GenerateClusterConfigForVersion(release.Version, framework.ExecuteWithEksaRelease(release)) + test.UpdateClusterConfig( + api.ClusterToConfigFiller( + api.WithKubernetesVersion(kubeVersion), + api.WithControlPlaneCount(1), + api.WithWorkerNodeCount(1), + ), + provider.WithKubeVersionAndOS(kubeVersion, os, release), + ) + + test.CreateCluster(framework.ExecuteWithEksaRelease(release)) + // upgrade management-components with new eksa + test.RunEKSA([]string{"upgrade", "management-components", "-f", test.ClusterConfigLocation, "-v", "99"}) + test.DeleteCluster() +} diff --git a/test/e2e/vsphere_test.go b/test/e2e/vsphere_test.go index 61aca70f63fa5..406944ce2aa0b 100644 --- a/test/e2e/vsphere_test.go +++ b/test/e2e/vsphere_test.go @@ -2587,6 +2587,12 @@ func TestVSphereKubernetes128UbuntuInPlaceWorkerScaleDown2To1(t *testing.T) { ) } +func TestVSphereKubernetes128UpgradeManagementComponents(t *testing.T) { + release := latestMinorRelease(t) + provider := framework.NewVSphere(t, framework.WithUbuntu128()) + runUpgradeManagementComponentsFlow(t, release, provider, v1alpha1.Kube128, framework.Ubuntu2004) +} + // Workload API func TestVSphereMulticlusterWorkloadClusterAPI(t *testing.T) { vsphere := framework.NewVSphere(t)