From ff55ac1ed20e06013b7e253d52daa5d54c46f46e Mon Sep 17 00:00:00 2001 From: Pankti Shah <58618433+panktishah26@users.noreply.github.com> Date: Tue, 24 Oct 2023 22:38:18 -0700 Subject: [PATCH] Remove kindless upgrade feature flag for all the providers (#6879) --- cmd/eksctl-anywhere/cmd/upgradecluster.go | 4 +- manager/main.go | 7 +- pkg/api/v1alpha1/cluster_webhook.go | 49 ++--- pkg/api/v1alpha1/cluster_webhook_test.go | 181 ++++-------------- .../v1alpha1/vspheremachineconfig_webhook.go | 65 ------- .../vspheremachineconfig_webhook_test.go | 82 ++++---- pkg/awsiamauth/reconciler/reconciler_test.go | 36 +++- pkg/clustermanager/eksa_installer.go | 9 +- pkg/clustermanager/eksa_installer_test.go | 13 -- pkg/controller/clusters/clusterapi.go | 46 ++--- pkg/controller/clusters/clusterapi_test.go | 102 +--------- pkg/features/features.go | 14 -- .../cloudstack/reconciler/reconciler_test.go | 83 ++++---- .../docker/reconciler/reconciler_test.go | 34 +++- .../snow/reconciler/reconciler_test.go | 66 +++++-- .../tinkerbell/reconciler/reconciler_test.go | 26 ++- .../vsphere/reconciler/reconciler_test.go | 82 +++++--- pkg/workflows/management/upgrade_test.go | 15 -- test/framework/cluster.go | 6 - 19 files changed, 347 insertions(+), 573 deletions(-) diff --git a/cmd/eksctl-anywhere/cmd/upgradecluster.go b/cmd/eksctl-anywhere/cmd/upgradecluster.go index 40452374d187..8bc1544d369e 100644 --- a/cmd/eksctl-anywhere/cmd/upgradecluster.go +++ b/cmd/eksctl-anywhere/cmd/upgradecluster.go @@ -11,7 +11,6 @@ import ( "github.com/aws/eks-anywhere/cmd/eksctl-anywhere/cmd/aflag" "github.com/aws/eks-anywhere/pkg/api/v1alpha1" "github.com/aws/eks-anywhere/pkg/dependencies" - "github.com/aws/eks-anywhere/pkg/features" "github.com/aws/eks-anywhere/pkg/kubeconfig" "github.com/aws/eks-anywhere/pkg/logger" "github.com/aws/eks-anywhere/pkg/providers/tinkerbell/hardware" @@ -199,8 +198,7 @@ func (uc *upgradeClusterOptions) upgradeCluster(cmd *cobra.Command, args []strin upgradeValidations := upgradevalidations.New(validationOpts) - if features.ExperimentalSelfManagedClusterUpgrade().IsActive() && clusterConfig.IsSelfManaged() { - logger.Info("Management kindless upgrade") + if clusterConfig.IsSelfManaged() { upgrade := management.NewUpgrade( deps.Provider, deps.CAPIManager, diff --git a/manager/main.go b/manager/main.go index 3dd5dfee5399..9f998d0ebad1 100644 --- a/manager/main.go +++ b/manager/main.go @@ -168,14 +168,9 @@ func setupReconcilers(ctx context.Context, setupLog logr.Logger, mgr ctrl.Manage os.Exit(1) } - expUpgrades := features.IsActive(features.ExperimentalSelfManagedClusterUpgrade()) - if expUpgrades { - setupLog.Info("[EXPERIMENTAL] Self-managed cluster upgrades enabled. Proceed with caution, this is not intended for production scenarios.") - } - factory := controllers.NewFactory(ctrl.Log, mgr). WithClusterReconciler( - providers, controllers.WithExperimentalSelfManagedClusterUpgrades(expUpgrades), + providers, ). WithVSphereDatacenterReconciler(). WithSnowMachineConfigReconciler(). diff --git a/pkg/api/v1alpha1/cluster_webhook.go b/pkg/api/v1alpha1/cluster_webhook.go index 7251f4dae13c..5e7c6a87ad84 100644 --- a/pkg/api/v1alpha1/cluster_webhook.go +++ b/pkg/api/v1alpha1/cluster_webhook.go @@ -26,7 +26,6 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/webhook" - "github.com/aws/eks-anywhere/pkg/features" "github.com/aws/eks-anywhere/pkg/semver" ) @@ -378,49 +377,25 @@ func validateImmutableFieldsCluster(new, old *Cluster) field.ErrorList { } } - if !old.IsSelfManaged() || features.IsActive(features.ExperimentalSelfManagedClusterUpgrade()) { - oldAWSIamConfig, newAWSIamConfig := &Ref{}, &Ref{} - for _, identityProvider := range new.Spec.IdentityProviderRefs { - if identityProvider.Kind == AWSIamConfigKind { - newAWSIamConfig = &identityProvider - break - } - } - - for _, identityProvider := range old.Spec.IdentityProviderRefs { - if identityProvider.Kind == AWSIamConfigKind { - oldAWSIamConfig = &identityProvider - break - } - } - - if !oldAWSIamConfig.Equal(newAWSIamConfig) { - allErrs = append( - allErrs, - field.Forbidden(specPath.Child("identityProviderRefs", AWSIamConfigKind), fmt.Sprintf("field is immutable %v", newAWSIamConfig.Kind))) + oldAWSIamConfig, newAWSIamConfig := &Ref{}, &Ref{} + for _, identityProvider := range new.Spec.IdentityProviderRefs { + if identityProvider.Kind == AWSIamConfigKind { + newAWSIamConfig = &identityProvider + break } - return allErrs } - clusterlog.Info("Cluster config is associated with management cluster", "name", old.Name) - - if !RefSliceEqual(new.Spec.IdentityProviderRefs, old.Spec.IdentityProviderRefs) { - allErrs = append( - allErrs, - field.Forbidden(specPath.Child("IdentityProviderRefs"), fmt.Sprintf("field is immutable %v", new.Spec.IdentityProviderRefs))) - } - - if old.Spec.KubernetesVersion != new.Spec.KubernetesVersion { - allErrs = append( - allErrs, - field.Forbidden(specPath.Child("kubernetesVersion"), fmt.Sprintf("field is immutable %v", new.Spec.KubernetesVersion)), - ) + for _, identityProvider := range old.Spec.IdentityProviderRefs { + if identityProvider.Kind == AWSIamConfigKind { + oldAWSIamConfig = &identityProvider + break + } } - if !old.Spec.ControlPlaneConfiguration.Equal(&new.Spec.ControlPlaneConfiguration) { + if !oldAWSIamConfig.Equal(newAWSIamConfig) { allErrs = append( allErrs, - field.Forbidden(specPath.Child("ControlPlaneConfiguration"), fmt.Sprintf("field is immutable %v", new.Spec.ControlPlaneConfiguration))) + field.Forbidden(specPath.Child("identityProviderRefs", AWSIamConfigKind), fmt.Sprintf("field is immutable %v", newAWSIamConfig.Kind))) } return allErrs diff --git a/pkg/api/v1alpha1/cluster_webhook_test.go b/pkg/api/v1alpha1/cluster_webhook_test.go index 87504de3009a..be47ae13be68 100644 --- a/pkg/api/v1alpha1/cluster_webhook_test.go +++ b/pkg/api/v1alpha1/cluster_webhook_test.go @@ -30,35 +30,6 @@ func TestClusterDefault(t *testing.T) { g.Expect(cOld.Spec.RegistryMirrorConfiguration.Port).To(Equal(constants.DefaultHttpsPort)) } -func TestClusterValidateUpdateManagementValueMutableExperimental(t *testing.T) { - features.ClearCache() - t.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "true") - cOld := baseCluster() - cOld.Spec.ControlPlaneConfiguration.Labels = map[string]string{"Key1": "Val1"} - cOld.Spec.ControlPlaneConfiguration.Taints = []v1.Taint{ - { - Key: "Key1", - Value: "Val1", - Effect: "PreferNoSchedule", - }, - } - cOld.SetSelfManaged() - cNew := cOld.DeepCopy() - cNew.Spec.ControlPlaneConfiguration.Labels = map[string]string{"Key2": "Val2"} - cNew.Spec.ControlPlaneConfiguration.Taints = []v1.Taint{ - { - Key: "Key2", - Value: "Val2", - Effect: "PreferNoSchedule", - }, - } - cNew.Spec.ControlPlaneConfiguration.Count = 1 - cNew.Spec.ControlPlaneConfiguration.MachineGroupRef.Name = "test" - - g := NewWithT(t) - g.Expect(cNew.ValidateUpdate(cOld)).To(Succeed()) -} - func TestClusterValidateUpdateManagementValueImmutable(t *testing.T) { cOld := baseCluster() cOld.SetSelfManaged() @@ -97,40 +68,14 @@ func TestClusterValidateUpdateManagementBothNilImmutable(t *testing.T) { g.Expect(c.ValidateUpdate(cOld)).To(Succeed()) } -func TestManagementClusterValidateUpdateKubernetesVersionImmutable(t *testing.T) { - features.ClearCache() - cOld := &v1alpha1.Cluster{ - Spec: v1alpha1.ClusterSpec{ - KubernetesVersion: v1alpha1.Kube119, - ExternalEtcdConfiguration: &v1alpha1.ExternalEtcdConfiguration{Count: 3}, - ControlPlaneConfiguration: v1alpha1.ControlPlaneConfiguration{ - Count: 3, Endpoint: &v1alpha1.Endpoint{Host: "1.1.1.1/1"}, - }, - }, - } +func TestManagementClusterValidateUpdateKubernetesVersionMutableManagement(t *testing.T) { + cOld := baseCluster() cOld.SetSelfManaged() c := cOld.DeepCopy() - c.Spec.KubernetesVersion = v1alpha1.Kube120 - - g := NewWithT(t) - g.Expect(c.ValidateUpdate(cOld)).To(MatchError(ContainSubstring("field is immutable 1.20"))) -} - -func TestManagementNilClusterValidateUpdateKubernetesVersionImmutable(t *testing.T) { - cOld := &v1alpha1.Cluster{ - Spec: v1alpha1.ClusterSpec{ - KubernetesVersion: v1alpha1.Kube122, - ExternalEtcdConfiguration: &v1alpha1.ExternalEtcdConfiguration{Count: 3}, - ControlPlaneConfiguration: v1alpha1.ControlPlaneConfiguration{ - Count: 3, Endpoint: &v1alpha1.Endpoint{Host: "1.1.1.1/1"}, - }, - }, - } - c := cOld.DeepCopy() - c.Spec.KubernetesVersion = v1alpha1.Kube120 + c.Spec.KubernetesVersion = v1alpha1.Kube122 g := NewWithT(t) - g.Expect(c.ValidateUpdate(cOld)).To(MatchError(ContainSubstring("field is immutable 1.20"))) + g.Expect(c.ValidateUpdate(cOld)).To(Succeed()) } func TestWorkloadClusterValidateUpdateKubernetesVersionSuccess(t *testing.T) { @@ -287,72 +232,55 @@ func TestCloudStackClusterValidateUpdateControlPlaneConfigurationOldPortImmutabl g.Expect(c.ValidateUpdate(cOld)).To(MatchError(ContainSubstring("spec.ControlPlaneConfiguration.endpoint: Forbidden: field is immutable"))) } -func TestManagementClusterValidateUpdateControlPlaneConfigurationTaintsImmutable(t *testing.T) { - features.ClearCache() - t.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "false") +func TestManagementClusterValidateUpdateControlPlaneConfigurationTaintsMutableManagement(t *testing.T) { cOld := baseCluster() - cOld.Spec.ControlPlaneConfiguration = v1alpha1.ControlPlaneConfiguration{ - Taints: []v1.Taint{ - { - Key: "Key1", - Value: "Val1", - Effect: "PreferNoSchedule", - }, + cOld.Spec.ControlPlaneConfiguration.Taints = []v1.Taint{ + { + Key: "Key1", + Value: "Val1", + Effect: "PreferNoSchedule", }, } + cOld.SetSelfManaged() c := cOld.DeepCopy() - c.Spec.ControlPlaneConfiguration = v1alpha1.ControlPlaneConfiguration{ - Taints: []v1.Taint{ - { - Key: "Key2", - Value: "Val2", - Effect: "PreferNoSchedule", - }, + c.Spec.ControlPlaneConfiguration.Taints = []v1.Taint{ + { + Key: "Key2", + Value: "Val2", + Effect: "PreferNoSchedule", }, } g := NewWithT(t) - g.Expect(c.ValidateUpdate(cOld)).To(MatchError(ContainSubstring("spec.ControlPlaneConfiguration: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(cOld)).To(Succeed()) } -func TestManagementClusterValidateUpdateControlPlaneConfigurationLabelsImmutable(t *testing.T) { - features.ClearCache() - t.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "false") +func TestManagementClusterValidateUpdateControlPlaneConfigurationLabelsMutableManagement(t *testing.T) { cOld := baseCluster() - cOld.Spec.ControlPlaneConfiguration = v1alpha1.ControlPlaneConfiguration{ - Labels: map[string]string{ - "Key1": "Val1", - }, + cOld.Spec.ControlPlaneConfiguration.Labels = map[string]string{ + "Key1": "Val1", } cOld.SetSelfManaged() c := cOld.DeepCopy() - c.Spec.ControlPlaneConfiguration = v1alpha1.ControlPlaneConfiguration{ - Labels: map[string]string{ - "Key2": "Val2", - }, + c.Spec.ControlPlaneConfiguration.Labels = map[string]string{ + "Key2": "Val2", } g := NewWithT(t) - g.Expect(c.ValidateUpdate(cOld)).To(MatchError(ContainSubstring("spec.ControlPlaneConfiguration: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(cOld)).To(Succeed()) } -func TestManagementClusterValidateUpdateControlPlaneConfigurationOldMachineGroupRefImmutable(t *testing.T) { - features.ClearCache() - t.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "false") +func TestManagementClusterValidateUpdateControlPlaneConfigurationOldMachineGroupRefMutableManagement(t *testing.T) { cOld := baseCluster() - cOld.Spec.ControlPlaneConfiguration = v1alpha1.ControlPlaneConfiguration{ - MachineGroupRef: &v1alpha1.Ref{Name: "test1", Kind: "MachineConfig"}, - } + cOld.Spec.ControlPlaneConfiguration.MachineGroupRef.Name = "test1" cOld.SetSelfManaged() c := cOld.DeepCopy() - c.Spec.ControlPlaneConfiguration = v1alpha1.ControlPlaneConfiguration{ - MachineGroupRef: &v1alpha1.Ref{Name: "test2", Kind: "MachineConfig"}, - } + c.Spec.ControlPlaneConfiguration.MachineGroupRef.Name = "test2" g := NewWithT(t) - g.Expect(c.ValidateUpdate(cOld)).To(MatchError(ContainSubstring("spec.ControlPlaneConfiguration: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(cOld)).To(Succeed()) } func TestWorkloadClusterValidateUpdateControlPlaneConfigurationMachineGroupRef(t *testing.T) { @@ -367,24 +295,6 @@ func TestWorkloadClusterValidateUpdateControlPlaneConfigurationMachineGroupRef(t g.Expect(c.ValidateUpdate(cOld)).To(Succeed()) } -func TestManagementClusterValidateUpdateControlPlaneConfigurationOldMachineGroupRefNilImmutable(t *testing.T) { - features.ClearCache() - t.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "false") - cOld := baseCluster() - cOld.Spec.ControlPlaneConfiguration = v1alpha1.ControlPlaneConfiguration{ - MachineGroupRef: nil, - } - cOld.SetSelfManaged() - - c := cOld.DeepCopy() - c.Spec.ControlPlaneConfiguration = v1alpha1.ControlPlaneConfiguration{ - MachineGroupRef: &v1alpha1.Ref{Name: "test", Kind: "MachineConfig"}, - } - - g := NewWithT(t) - g.Expect(c.ValidateUpdate(cOld)).To(MatchError(ContainSubstring("spec.ControlPlaneConfiguration: Forbidden: field is immutable"))) -} - func TestWorkloadClusterValidateUpdateControlPlaneConfigurationOldMachineGroupRefNilSuccess(t *testing.T) { cOld := baseCluster() cOld.Spec.ControlPlaneConfiguration.MachineGroupRef = nil @@ -398,12 +308,7 @@ func TestWorkloadClusterValidateUpdateControlPlaneConfigurationOldMachineGroupRe } func TestManagementClusterValidateUpdateControlPlaneConfigurationNewMachineGroupRefNilImmutable(t *testing.T) { - features.ClearCache() - t.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "false") cOld := baseCluster() - cOld.Spec.ControlPlaneConfiguration = v1alpha1.ControlPlaneConfiguration{ - MachineGroupRef: &v1alpha1.Ref{Name: "test", Kind: "MachineConfig"}, - } cOld.SetSelfManaged() c := cOld.DeepCopy() @@ -412,7 +317,7 @@ func TestManagementClusterValidateUpdateControlPlaneConfigurationNewMachineGroup } g := NewWithT(t) - g.Expect(c.ValidateUpdate(cOld)).To(MatchError(ContainSubstring("spec.ControlPlaneConfiguration: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(cOld)).To(MatchError(ContainSubstring("ControlPlaneConfiguration.endpoint: Forbidden: field is immutable"))) } func TestWorkloadClusterValidateUpdateControlPlaneConfigurationNewMachineGroupRefChangedSuccess(t *testing.T) { @@ -823,7 +728,7 @@ func TestClusterValidateUpdateAWSIamNameImmutableUpdateName(t *testing.T) { } g := NewWithT(t) - g.Expect(c.ValidateUpdate(cOld)).To(MatchError(ContainSubstring("spec.IdentityProviderRefs: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(cOld)).To(MatchError(ContainSubstring("spec.identityProviderRefs.AWSIamConfig: Forbidden: field is immutable"))) } func TestClusterValidateUpdateAWSIamNameImmutableEmpty(t *testing.T) { @@ -838,7 +743,7 @@ func TestClusterValidateUpdateAWSIamNameImmutableEmpty(t *testing.T) { c.Spec.IdentityProviderRefs = []v1alpha1.Ref{} g := NewWithT(t) - g.Expect(c.ValidateUpdate(cOld)).To(MatchError(ContainSubstring("spec.IdentityProviderRefs: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(cOld)).To(MatchError(ContainSubstring("spec.identityProviderRefs.AWSIamConfig: Forbidden: field is immutable"))) } func TestClusterValidateUpdateAWSIamNameImmutableAddConfig(t *testing.T) { @@ -853,7 +758,7 @@ func TestClusterValidateUpdateAWSIamNameImmutableAddConfig(t *testing.T) { } g := NewWithT(t) - g.Expect(c.ValidateUpdate(cOld)).To(MatchError(ContainSubstring("spec.IdentityProviderRefs: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(cOld)).To(MatchError(ContainSubstring("spec.identityProviderRefs.AWSIamConfig: Forbidden: field is immutable"))) } func TestClusterValidateUpdateUnsetBundlesRefImmutable(t *testing.T) { @@ -978,7 +883,7 @@ func TestClusterValidateUpdateOIDCNameMutableUpdateNameMgmtCluster(t *testing.T) c.Spec.IdentityProviderRefs[0].Name = "name2" g := NewWithT(t) - g.Expect(c.ValidateUpdate(cOld)).To(MatchError(ContainSubstring("spec.IdentityProviderRefs: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(cOld)).To(Succeed()) } func TestClusterValidateUpdateOIDCNameMutableUpdateNameUnchanged(t *testing.T) { @@ -1025,7 +930,7 @@ func TestClusterValidateUpdateOIDCNameMutableMgmtCluster(t *testing.T) { c.Spec.IdentityProviderRefs = []v1alpha1.Ref{} g := NewWithT(t) - g.Expect(c.ValidateUpdate(cOld)).To(MatchError(ContainSubstring("spec.IdentityProviderRefs: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(cOld)).To(Succeed()) } func TestClusterValidateUpdateOIDCNameMutableAddConfigWorkloadCluster(t *testing.T) { @@ -1059,7 +964,7 @@ func TestClusterValidateUpdateOIDCNameMutableAddConfigMgmtCluster(t *testing.T) }, } g := NewWithT(t) - g.Expect(c.ValidateUpdate(cOld)).To(MatchError(ContainSubstring("spec.IdentityProviderRefs: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(cOld)).To(Succeed()) } func TestClusterValidateUpdateSwapIdentityProviders(t *testing.T) { @@ -1129,18 +1034,13 @@ func TestClusterValidateEmptyIdentityProviders(t *testing.T) { g.Expect(c.ValidateUpdate(cOld)).To(Succeed()) } -func TestClusterValidateUpdateGitOpsRefOldEmptyImmutable(t *testing.T) { +func TestClusterValidateUpdateGitOpsRefOldEmptyMutableManagement(t *testing.T) { cOld := baseCluster() c := cOld.DeepCopy() - c.Spec.IdentityProviderRefs = []v1alpha1.Ref{ - { - Kind: "identity", - Name: "name", - }, - } + c.Spec.IdentityProviderRefs = []v1alpha1.Ref{} g := NewWithT(t) - g.Expect(c.ValidateUpdate(cOld)).To(MatchError(ContainSubstring("spec.IdentityProviderRefs: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(cOld)).To(Succeed()) } func TestClusterValidateUpdateWithPausedAnnotation(t *testing.T) { @@ -1836,17 +1736,16 @@ func TestClusterValidateUpdateValidWorkloadCluster(t *testing.T) { } } -func TestClusterValidateUpdateInvalidRequest(t *testing.T) { +func TestClusterValidateUpdateValidRequest(t *testing.T) { features.ClearCache() cOld := baseCluster() cOld.SetSelfManaged() - t.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "false") cNew := cOld.DeepCopy() - cNew.Spec.ControlPlaneConfiguration.Count = cNew.Spec.ControlPlaneConfiguration.Count + 1 + cNew.Spec.ControlPlaneConfiguration.Count = cNew.Spec.ControlPlaneConfiguration.Count + 2 g := NewWithT(t) err := cNew.ValidateUpdate(cOld) - g.Expect(err).To(MatchError(ContainSubstring("spec.ControlPlaneConfiguration: Forbidden: field is immutable"))) + g.Expect(err).To(Succeed()) } func TestClusterValidateUpdateRollingAndScalingTinkerbellRequest(t *testing.T) { diff --git a/pkg/api/v1alpha1/vspheremachineconfig_webhook.go b/pkg/api/v1alpha1/vspheremachineconfig_webhook.go index 16752ef01530..307cf88b7f30 100644 --- a/pkg/api/v1alpha1/vspheremachineconfig_webhook.go +++ b/pkg/api/v1alpha1/vspheremachineconfig_webhook.go @@ -2,7 +2,6 @@ package v1alpha1 import ( "fmt" - "reflect" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" @@ -10,8 +9,6 @@ import ( ctrl "sigs.k8s.io/controller-runtime" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/webhook" - - "github.com/aws/eks-anywhere/pkg/features" ) // log is for logging in this package. @@ -131,68 +128,6 @@ func validateImmutableFieldsVSphereMachineConfig(new, old *VSphereMachineConfig) return allErrs } - if features.IsActive(features.ExperimentalSelfManagedClusterUpgrade()) { - return allErrs - } - - vspheremachineconfiglog.Info("Machine config is associated with management cluster's control plane or etcd", "name", old.Name) - - if !reflect.DeepEqual(old.Spec.Users, new.Spec.Users) { - allErrs = append( - allErrs, - field.Forbidden(specPath.Child("users"), "field is immutable"), - ) - } - - if old.Spec.Template != new.Spec.Template { - allErrs = append( - allErrs, - field.Forbidden(specPath.Child("template"), "field is immutable"), - ) - } - - if old.Spec.Datastore != new.Spec.Datastore { - allErrs = append( - allErrs, - field.Forbidden(specPath.Child("datastore"), "field is immutable"), - ) - } - - if old.Spec.Folder != new.Spec.Folder { - allErrs = append( - allErrs, - field.Forbidden(specPath.Child("folder"), "field is immutable"), - ) - } - - if old.Spec.ResourcePool != new.Spec.ResourcePool { - allErrs = append( - allErrs, - field.Forbidden(specPath.Child("resourcePool"), "field is immutable"), - ) - } - - if old.Spec.MemoryMiB != new.Spec.MemoryMiB { - allErrs = append( - allErrs, - field.Forbidden(specPath.Child("memoryMiB"), "field is immutable"), - ) - } - - if old.Spec.NumCPUs != new.Spec.NumCPUs { - allErrs = append( - allErrs, - field.Forbidden(specPath.Child("numCPUs"), "field is immutable"), - ) - } - - if old.Spec.DiskGiB != new.Spec.DiskGiB { - allErrs = append( - allErrs, - field.Forbidden(specPath.Child("diskGiB"), "field is immutable"), - ) - } - return allErrs } diff --git a/pkg/api/v1alpha1/vspheremachineconfig_webhook_test.go b/pkg/api/v1alpha1/vspheremachineconfig_webhook_test.go index 778cd8f7702c..c36c77f7ecb7 100644 --- a/pkg/api/v1alpha1/vspheremachineconfig_webhook_test.go +++ b/pkg/api/v1alpha1/vspheremachineconfig_webhook_test.go @@ -9,7 +9,7 @@ import ( "github.com/aws/eks-anywhere/pkg/api/v1alpha1" ) -func TestManagementCPVSphereMachineValidateUpdateTemplateImmutable(t *testing.T) { +func TestManagementCPVSphereMachineValidateUpdateTemplateMutableManagement(t *testing.T) { vOld := vsphereMachineConfig() vOld.SetControlPlane() vOld.Spec.Template = "oldTemplate" @@ -17,7 +17,7 @@ func TestManagementCPVSphereMachineValidateUpdateTemplateImmutable(t *testing.T) c.Spec.Template = "newTemplate" g := NewWithT(t) - g.Expect(c.ValidateUpdate(&vOld)).To(MatchError(ContainSubstring("spec.template: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } func TestWorkloadCPVSphereMachineValidateUpdateTemplateSuccess(t *testing.T) { @@ -53,7 +53,7 @@ func TestWorkloadWorkersVSphereMachineValidateUpdateTemplateSuccess(t *testing.T g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } -func TestManagementEtcdVSphereMachineValidateUpdateTemplateImmutable(t *testing.T) { +func TestManagementEtcdVSphereMachineValidateEtcdUpdateTemplateMutable(t *testing.T) { vOld := vsphereMachineConfig() vOld.SetEtcd() vOld.Spec.Template = "oldTemplate" @@ -61,7 +61,7 @@ func TestManagementEtcdVSphereMachineValidateUpdateTemplateImmutable(t *testing. c.Spec.Template = "newTemplate" g := NewWithT(t) - g.Expect(c.ValidateUpdate(&vOld)).To(MatchError(ContainSubstring("spec.template: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } func TestWorkloadEtcdVSphereMachineValidateUpdateTemplateSuccess(t *testing.T) { @@ -87,7 +87,7 @@ func TestVSphereMachineValidateUpdateOSFamilyImmutable(t *testing.T) { g.Expect(c.ValidateUpdate(&vOld)).To(MatchError(ContainSubstring("spec.osFamily: Forbidden: field is immutable"))) } -func TestManagementCPVSphereMachineValidateUpdateMemoryMiBImmutable(t *testing.T) { +func TestManagementCPVSphereMachineValidateUpdateMemoryMiBMutableManagement(t *testing.T) { vOld := vsphereMachineConfig() vOld.SetControlPlane() vOld.Spec.MemoryMiB = 2 @@ -95,7 +95,7 @@ func TestManagementCPVSphereMachineValidateUpdateMemoryMiBImmutable(t *testing.T c.Spec.MemoryMiB = 2000000 g := NewWithT(t) - g.Expect(c.ValidateUpdate(&vOld)).To(MatchError(ContainSubstring("spec.memoryMiB: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } func TestWorkloadCPVSphereMachineValidateUpdateMemoryMiBSuccess(t *testing.T) { @@ -140,7 +140,7 @@ func TestManagementEtcdVSphereMachineValidateUpdateMemoryMiBImmutable(t *testing c.Spec.MemoryMiB = 2000000 g := NewWithT(t) - g.Expect(c.ValidateUpdate(&vOld)).To(MatchError(ContainSubstring("spec.memoryMiB: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } func TestWorkloadEtcdVSphereMachineValidateUpdateMemoryMiBSuccess(t *testing.T) { @@ -155,7 +155,7 @@ func TestWorkloadEtcdVSphereMachineValidateUpdateMemoryMiBSuccess(t *testing.T) g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } -func TestManagementCPVSphereMachineValidateUpdateNumCPUsImmutable(t *testing.T) { +func TestManagementCPVSphereMachineValidateUpdateNumCPUsMutableManagement(t *testing.T) { vOld := vsphereMachineConfig() vOld.SetControlPlane() vOld.Spec.NumCPUs = 1 @@ -163,7 +163,7 @@ func TestManagementCPVSphereMachineValidateUpdateNumCPUsImmutable(t *testing.T) c.Spec.NumCPUs = 16 g := NewWithT(t) - g.Expect(c.ValidateUpdate(&vOld)).To(MatchError(ContainSubstring("spec.numCPUs: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } func TestWorkloadCPVSphereMachineValidateUpdateNumCPUsSuccess(t *testing.T) { @@ -199,7 +199,7 @@ func TestWorkloadWorkersVSphereMachineValidateUpdateNumCPUsSuccess(t *testing.T) g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } -func TestManagementEtcdVSphereMachineValidateUpdateNumCPUsImmutable(t *testing.T) { +func TestManagementEtcdVSphereMachineValidateUpdateNumCPUsMmutableManagement(t *testing.T) { vOld := vsphereMachineConfig() vOld.SetEtcd() vOld.Spec.NumCPUs = 1 @@ -207,7 +207,7 @@ func TestManagementEtcdVSphereMachineValidateUpdateNumCPUsImmutable(t *testing.T c.Spec.NumCPUs = 16 g := NewWithT(t) - g.Expect(c.ValidateUpdate(&vOld)).To(MatchError(ContainSubstring("spec.numCPUs: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } func TestWorkloadEtcdVSphereMachineValidateUpdateNumCPUsSuccess(t *testing.T) { @@ -222,7 +222,7 @@ func TestWorkloadEtcdVSphereMachineValidateUpdateNumCPUsSuccess(t *testing.T) { g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } -func TestManagementCPVSphereMachineValidateUpdateDiskGiBImmutable(t *testing.T) { +func TestManagementCPVSphereMachineValidateUpdateDiskGiBMutableManagement(t *testing.T) { vOld := vsphereMachineConfig() vOld.SetControlPlane() vOld.Spec.DiskGiB = 1 @@ -230,7 +230,7 @@ func TestManagementCPVSphereMachineValidateUpdateDiskGiBImmutable(t *testing.T) c.Spec.DiskGiB = 160 g := NewWithT(t) - g.Expect(c.ValidateUpdate(&vOld)).To(MatchError(ContainSubstring("spec.diskGiB: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } func TestWorkloadCPVSphereMachineValidateUpdateDiskGiBSuccess(t *testing.T) { @@ -266,7 +266,7 @@ func TestWorkloadWorkersVSphereMachineValidateUpdateDiskGiBSuccess(t *testing.T) g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } -func TestManagementEtcdVSphereMachineValidateUpdateDiskGiBImmutable(t *testing.T) { +func TestManagementEtcdVSphereMachineValidateUpdateDiskGiBMmutableManagement(t *testing.T) { vOld := vsphereMachineConfig() vOld.SetEtcd() vOld.Spec.DiskGiB = 1 @@ -275,7 +275,7 @@ func TestManagementEtcdVSphereMachineValidateUpdateDiskGiBImmutable(t *testing.T c.Spec.DiskGiB = 160 g := NewWithT(t) - g.Expect(c.ValidateUpdate(&vOld)).To(MatchError(ContainSubstring("spec.diskGiB: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } func TestWorkloadEtcdVSphereMachineValidateUpdateDiskGiBSuccess(t *testing.T) { @@ -290,7 +290,7 @@ func TestWorkloadEtcdVSphereMachineValidateUpdateDiskGiBSuccess(t *testing.T) { g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } -func TestManagementControlPlaneSphereMachineValidateUpdateSshAuthorizedKeyImmutable(t *testing.T) { +func TestManagementControlPlaneSphereMachineValidateUpdateSshAuthorizedKeyMutableManagement(t *testing.T) { vOld := vsphereMachineConfig() vOld.SetControlPlane() vOld.Spec.Users = []v1alpha1.UserConfiguration{{Name: "Jeff"}} @@ -299,10 +299,10 @@ func TestManagementControlPlaneSphereMachineValidateUpdateSshAuthorizedKeyImmuta c.Spec.Users[0].SshAuthorizedKeys[0] = "rsa-laDeLala" g := NewWithT(t) - g.Expect(c.ValidateUpdate(&vOld)).To(MatchError(ContainSubstring("spec.users: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } -func TestWorkloadControlPlaneVSphereMachineValidateUpdateSshAuthorizedKeyImmutable(t *testing.T) { +func TestWorkloadControlPlaneVSphereMachineValidateUpdateSshAuthorizedKeyMutable(t *testing.T) { vOld := vsphereMachineConfig() vOld.SetControlPlane() vOld.SetManagedBy("test-cluster") @@ -323,10 +323,10 @@ func TestManagementControlPlaneVSphereMachineValidateUpdateSshUsernameImmutable( c.Spec.Users[0].Name = "Andy" g := NewWithT(t) - g.Expect(c.ValidateUpdate(&vOld)).To(MatchError(ContainSubstring("spec.users: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } -func TestWorkloadControlPlaneVSphereMachineValidateUpdateSshUsernameImmutable(t *testing.T) { +func TestWorkloadControlPlaneVSphereMachineValidateUpdateSshUsernameMutable(t *testing.T) { vOld := vsphereMachineConfig() vOld.SetControlPlane() vOld.SetManagedBy("test-cluster") @@ -354,7 +354,7 @@ func TestVSphereMachineValidateUpdateWithPausedAnnotation(t *testing.T) { g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } -func TestManagementEtcdSphereMachineValidateUpdateSshAuthorizedKeyImmutable(t *testing.T) { +func TestManagementEtcdSphereMachineValidateUpdateSshAuthorizedKeyMutableManagement(t *testing.T) { vOld := vsphereMachineConfig() vOld.SetEtcd() vOld.Spec.Users = []v1alpha1.UserConfiguration{{Name: "Jeff"}} @@ -363,7 +363,7 @@ func TestManagementEtcdSphereMachineValidateUpdateSshAuthorizedKeyImmutable(t *t c.Spec.Users[0].SshAuthorizedKeys[0] = "rsa-laDeLala" g := NewWithT(t) - g.Expect(c.ValidateUpdate(&vOld)).To(MatchError(ContainSubstring("spec.users: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } func TestWorkloadEtcdVSphereMachineValidateUpdateSshAuthorizedKeyImmutable(t *testing.T) { @@ -379,7 +379,7 @@ func TestWorkloadEtcdVSphereMachineValidateUpdateSshAuthorizedKeyImmutable(t *te g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } -func TestManagementEtcdVSphereMachineValidateUpdateSshUsernameImmutable(t *testing.T) { +func TestManagementEtcdVSphereMachineValidateUpdateSshUsernameMutable(t *testing.T) { vOld := vsphereMachineConfig() vOld.SetEtcd() vOld.Spec.Users[0].Name = "Jeff" @@ -387,10 +387,10 @@ func TestManagementEtcdVSphereMachineValidateUpdateSshUsernameImmutable(t *testi c.Spec.Users[0].Name = "Andy" g := NewWithT(t) - g.Expect(c.ValidateUpdate(&vOld)).To(MatchError(ContainSubstring("spec.users: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } -func TestWorkloadEtcdVSphereMachineValidateUpdateSshUsernameImmutable(t *testing.T) { +func TestWorkloadEtcdVSphereMachineValidateUpdateSshUsernameMutable(t *testing.T) { vOld := vsphereMachineConfig() vOld.SetEtcd() vOld.SetManagedBy("test-cluster") @@ -402,7 +402,7 @@ func TestWorkloadEtcdVSphereMachineValidateUpdateSshUsernameImmutable(t *testing g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } -func TestManagementWorkerNodeSphereMachineValidateUpdateSshAuthorizedKeyImmutable(t *testing.T) { +func TestManagementWorkerNodeSphereMachineValidateUpdateSshAuthorizedKeyMutable(t *testing.T) { vOld := vsphereMachineConfig() vOld.Spec.Users = []v1alpha1.UserConfiguration{{Name: "Jeff"}} vOld.Spec.Users[0].SshAuthorizedKeys = []string{"rsa-blahdeblahbalh"} @@ -413,7 +413,7 @@ func TestManagementWorkerNodeSphereMachineValidateUpdateSshAuthorizedKeyImmutabl g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } -func TestWorkloadWorkerNodeVSphereMachineValidateUpdateSshAuthorizedKeyImmutable(t *testing.T) { +func TestWorkloadWorkerNodeVSphereMachineValidateUpdateSshAuthorizedKeyMutable(t *testing.T) { vOld := vsphereMachineConfig() vOld.SetManagedBy("test-cluster") vOld.Spec.Users = []v1alpha1.UserConfiguration{{Name: "Jeff"}} @@ -425,7 +425,7 @@ func TestWorkloadWorkerNodeVSphereMachineValidateUpdateSshAuthorizedKeyImmutable g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } -func TestManagementWorkerNodeVSphereMachineValidateUpdateSshUsernameImmutable(t *testing.T) { +func TestManagementWorkerNodeVSphereMachineValidateUpdateSshUsernameMutable(t *testing.T) { vOld := vsphereMachineConfig() vOld.Spec.Users[0].Name = "Jeff" c := vOld.DeepCopy() @@ -435,7 +435,7 @@ func TestManagementWorkerNodeVSphereMachineValidateUpdateSshUsernameImmutable(t g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } -func TestWorkloadWorkerNodeVSphereMachineValidateUpdateSshUsernameImmutable(t *testing.T) { +func TestWorkloadWorkerNodeVSphereMachineValidateUpdateSshUsernameMutable(t *testing.T) { vOld := vsphereMachineConfig() vOld.SetManagedBy("test-cluster") vOld.Spec.Users[0].Name = "Jeff" @@ -480,7 +480,7 @@ func TestVSphereMachineValidateUpdateBottleRocketInvalidUserName(t *testing.T) { g.Expect(c.ValidateUpdate(&vOld)).ToNot(Succeed()) } -func TestManagementCPVSphereMachineValidateUpdateDatastoreImmutable(t *testing.T) { +func TestManagementCPVSphereMachineValidateUpdateDatastoreMutableSuccess(t *testing.T) { vOld := vsphereMachineConfig() vOld.SetControlPlane() vOld.Spec.Datastore = "OldDataStore" @@ -488,7 +488,7 @@ func TestManagementCPVSphereMachineValidateUpdateDatastoreImmutable(t *testing.T c.Spec.Datastore = "NewDataStore" g := NewWithT(t) - g.Expect(c.ValidateUpdate(&vOld)).To(MatchError(ContainSubstring("spec.datastore: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } func TestWorkloadCPVSphereMachineValidateUpdateDatastoreSuccess(t *testing.T) { @@ -503,7 +503,7 @@ func TestWorkloadCPVSphereMachineValidateUpdateDatastoreSuccess(t *testing.T) { g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } -func TestManagementEtcdVSphereMachineValidateUpdateDatastoreImmutable(t *testing.T) { +func TestManagementEtcdVSphereMachineValidateUpdateDatastoreMutableManagement(t *testing.T) { vOld := vsphereMachineConfig() vOld.SetEtcd() vOld.Spec.Datastore = "OldDataStore" @@ -511,7 +511,7 @@ func TestManagementEtcdVSphereMachineValidateUpdateDatastoreImmutable(t *testing c.Spec.Datastore = "NewDataStore" g := NewWithT(t) - g.Expect(c.ValidateUpdate(&vOld)).To(MatchError(ContainSubstring("spec.datastore: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } func TestWorkloadEtcdVSphereMachineValidateUpdateDatastoreSuccess(t *testing.T) { @@ -547,7 +547,7 @@ func TestWorkloadWorkersVSphereMachineValidateUpdateDatastoreSuccess(t *testing. g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } -func TestManagementCPVSphereMachineValidateUpdateFolderImmutable(t *testing.T) { +func TestManagementCPVSphereMachineValidateUpdateFolderMutableManagement(t *testing.T) { vOld := vsphereMachineConfig() vOld.SetControlPlane() vOld.Spec.Folder = "/dev/null" @@ -555,7 +555,7 @@ func TestManagementCPVSphereMachineValidateUpdateFolderImmutable(t *testing.T) { c.Spec.Folder = "/tmp" g := NewWithT(t) - g.Expect(c.ValidateUpdate(&vOld)).To(MatchError(ContainSubstring("spec.folder: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } func TestWorkloadCPVSphereMachineValidateUpdateFolderSuccess(t *testing.T) { @@ -570,7 +570,7 @@ func TestWorkloadCPVSphereMachineValidateUpdateFolderSuccess(t *testing.T) { g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } -func TestManagementEtcdVSphereMachineValidateUpdateFolderImmutable(t *testing.T) { +func TestManagementEtcdVSphereMachineValidateUpdateFolderMutableManagement(t *testing.T) { vOld := vsphereMachineConfig() vOld.SetEtcd() vOld.Spec.Folder = "/dev/null" @@ -578,7 +578,7 @@ func TestManagementEtcdVSphereMachineValidateUpdateFolderImmutable(t *testing.T) c.Spec.Folder = "/tmp" g := NewWithT(t) - g.Expect(c.ValidateUpdate(&vOld)).To(MatchError(ContainSubstring("spec.folder: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } func TestWorkloadEtcdVSphereMachineValidateUpdateFolderSuccess(t *testing.T) { @@ -614,7 +614,7 @@ func TestWorkloadWorkersVSphereMachineValidateUpdateFolderSuccess(t *testing.T) g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } -func TestManagementCPVSphereMachineValidateUpdateResourcePoolImmutable(t *testing.T) { +func TestManagementCPVSphereMachineValidateUpdateResourcePoolMutableManagemenmt(t *testing.T) { vOld := vsphereMachineConfig() vOld.SetControlPlane() vOld.Spec.ResourcePool = "AbovegroundPool" @@ -622,7 +622,7 @@ func TestManagementCPVSphereMachineValidateUpdateResourcePoolImmutable(t *testin c.Spec.ResourcePool = "IngroundPool" g := NewWithT(t) - g.Expect(c.ValidateUpdate(&vOld)).To(MatchError(ContainSubstring("spec.resourcePool: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } func TestWorkloadCPVSphereMachineValidateUpdateResourcePoolSuccess(t *testing.T) { @@ -637,7 +637,7 @@ func TestWorkloadCPVSphereMachineValidateUpdateResourcePoolSuccess(t *testing.T) g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } -func TestManagementEtcdVSphereMachineValidateUpdateResourcePoolImmutable(t *testing.T) { +func TestManagementEtcdVSphereMachineValidateUpdateResourcePoolMutableManagement(t *testing.T) { vOld := vsphereMachineConfig() vOld.SetEtcd() vOld.Spec.ResourcePool = "AbovegroundPool" @@ -645,7 +645,7 @@ func TestManagementEtcdVSphereMachineValidateUpdateResourcePoolImmutable(t *test c.Spec.ResourcePool = "IngroundPool" g := NewWithT(t) - g.Expect(c.ValidateUpdate(&vOld)).To(MatchError(ContainSubstring("spec.resourcePool: Forbidden: field is immutable"))) + g.Expect(c.ValidateUpdate(&vOld)).To(Succeed()) } func TestWorkloadEtcdVSphereMachineValidateUpdateResourcePoolSuccess(t *testing.T) { diff --git a/pkg/awsiamauth/reconciler/reconciler_test.go b/pkg/awsiamauth/reconciler/reconciler_test.go index 9586334784db..2fa1aa1e9d65 100644 --- a/pkg/awsiamauth/reconciler/reconciler_test.go +++ b/pkg/awsiamauth/reconciler/reconciler_test.go @@ -15,6 +15,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + controlplanev1 "sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" logf "sigs.k8s.io/controller-runtime/pkg/log" @@ -164,7 +165,7 @@ func TestReconcileBuildClusterSpecError(t *testing.T) { g.Expect(result).To(Equal(controller.Result{})) } -func TestReconcileCAPIClusterNotFound(t *testing.T) { +func TestReconcileKCPObjectNotFound(t *testing.T) { g := NewWithT(t) ctx := context.Background() ctrl := gomock.NewController(t) @@ -181,6 +182,7 @@ func TestReconcileCAPIClusterNotFound(t *testing.T) { _ = releasev1.AddToScheme(scheme) _ = eksdv1.AddToScheme(scheme) _ = clusterv1.AddToScheme(scheme) + _ = controlplanev1.AddToScheme(scheme) cl := cb.WithScheme(scheme).WithRuntimeObjects(objs...).Build() version := test.DevEksaVersion() @@ -233,8 +235,17 @@ func TestReconcileRemoteGetClientError(t *testing.T) { EksaVersion: &version, }, } - capiCluster := test.CAPICluster(func(c *clusterv1.Cluster) { - c.Name = cluster.Name + kcp := test.KubeadmControlPlane(func(kcp *controlplanev1.KubeadmControlPlane) { + kcp.Name = cluster.Name + kcp.Status = controlplanev1.KubeadmControlPlaneStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterapi.ReadyCondition, + Status: corev1.ConditionTrue, + LastTransitionTime: metav1.NewTime(time.Now()), + }, + }, + } }) sec := &corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ @@ -242,13 +253,14 @@ func TestReconcileRemoteGetClientError(t *testing.T) { Namespace: constants.EksaSystemNamespace, }, } - objs := []runtime.Object{bundle, eksdRelease, capiCluster, sec, eksaRelease} + objs := []runtime.Object{bundle, eksdRelease, kcp, sec, eksaRelease} cb := fake.NewClientBuilder() scheme := runtime.NewScheme() _ = releasev1.AddToScheme(scheme) _ = eksdv1.AddToScheme(scheme) _ = clusterv1.AddToScheme(scheme) _ = corev1.AddToScheme(scheme) + _ = controlplanev1.AddToScheme(scheme) cl := cb.WithScheme(scheme).WithRuntimeObjects(objs...).Build() remoteClientRegistry.EXPECT().GetClient(context.Background(), gomock.AssignableToTypeOf(client.ObjectKey{})).Return(nil, errors.New("client error")) @@ -297,8 +309,17 @@ func TestReconcileConfigMapNotFoundApplyError(t *testing.T) { EksaVersion: &version, }, } - capiCluster := test.CAPICluster(func(c *clusterv1.Cluster) { - c.Name = cluster.Name + kcp := test.KubeadmControlPlane(func(kcp *controlplanev1.KubeadmControlPlane) { + kcp.Name = cluster.Name + kcp.Status = controlplanev1.KubeadmControlPlaneStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterapi.ReadyCondition, + Status: corev1.ConditionTrue, + LastTransitionTime: metav1.NewTime(time.Now()), + }, + }, + } }) sec := &corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ @@ -321,7 +342,7 @@ func TestReconcileConfigMapNotFoundApplyError(t *testing.T) { Namespace: "eksa-system", }, } - objs := []runtime.Object{bundle, eksdRelease, capiCluster, sec, awsiamconfig, caSec, eksaRelease} + objs := []runtime.Object{bundle, eksdRelease, kcp, sec, awsiamconfig, caSec, eksaRelease} cb := fake.NewClientBuilder() scheme := runtime.NewScheme() _ = anywherev1.AddToScheme(scheme) @@ -329,6 +350,7 @@ func TestReconcileConfigMapNotFoundApplyError(t *testing.T) { _ = eksdv1.AddToScheme(scheme) _ = clusterv1.AddToScheme(scheme) _ = corev1.AddToScheme(scheme) + _ = controlplanev1.AddToScheme(scheme) cl := cb.WithScheme(scheme).WithRuntimeObjects(objs...).Build() rCb := fake.NewClientBuilder() diff --git a/pkg/clustermanager/eksa_installer.go b/pkg/clustermanager/eksa_installer.go index c0eb737f5cb6..090c479c6034 100644 --- a/pkg/clustermanager/eksa_installer.go +++ b/pkg/clustermanager/eksa_installer.go @@ -18,7 +18,6 @@ import ( anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1" "github.com/aws/eks-anywhere/pkg/cluster" "github.com/aws/eks-anywhere/pkg/constants" - "github.com/aws/eks-anywhere/pkg/features" "github.com/aws/eks-anywhere/pkg/manifests" "github.com/aws/eks-anywhere/pkg/manifests/bundles" "github.com/aws/eks-anywhere/pkg/types" @@ -163,13 +162,7 @@ func setManagerEnvVars(d *appsv1.Deployment, spec *cluster.Spec) { } func managerEnabledGates(spec *cluster.Spec) []string { - g := []string{} - // TODO(pjshah): remove this feature flag after we implement kindless upgrade managaement feature for all the providers. - if features.IsActive(features.ExperimentalSelfManagedClusterUpgrade()) { - g = append(g, features.ExperimentalSelfManagedClusterUpgradeGate) - } - - return g + return nil } func fullLifeCycleControllerForProvider(cluster *anywherev1.Cluster) bool { diff --git a/pkg/clustermanager/eksa_installer_test.go b/pkg/clustermanager/eksa_installer_test.go index 599d5b8e1d4b..709b60e9ceca 100644 --- a/pkg/clustermanager/eksa_installer_test.go +++ b/pkg/clustermanager/eksa_installer_test.go @@ -2,7 +2,6 @@ package clustermanager_test import ( "context" - "os" "testing" "github.com/go-logr/logr" @@ -214,21 +213,9 @@ func TestSetManagerFlags(t *testing.T) { spec: test.NewClusterSpec(), want: deployment(), }, - { - name: "kindless upgrades, feature flag enabled", - deployment: deployment(), - spec: test.NewClusterSpec(), - featureEnvVars: []string{features.ExperimentalSelfManagedClusterUpgradeEnvVar}, - want: deployment(func(d *appsv1.Deployment) { - d.Spec.Template.Spec.Containers[0].Args = []string{ - "--feature-gates=ExpSelfManagedAPIUpgrade=true", - } - }), - }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - os.Unsetenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar) features.ClearCache() for _, e := range tt.featureEnvVars { t.Setenv(e, "true") diff --git a/pkg/controller/clusters/clusterapi.go b/pkg/controller/clusters/clusterapi.go index 4070349e5ee2..f72afdaa5be0 100644 --- a/pkg/controller/clusters/clusterapi.go +++ b/pkg/controller/clusters/clusterapi.go @@ -11,7 +11,6 @@ import ( anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1" "github.com/aws/eks-anywhere/pkg/clusterapi" "github.com/aws/eks-anywhere/pkg/controller" - "github.com/aws/eks-anywhere/pkg/features" ) // CheckControlPlaneReady is a controller helper to check whether KCP object for @@ -19,48 +18,27 @@ import ( // due its signature and that it returns controller results with appropriate wait times whenever // the cluster is not ready. func CheckControlPlaneReady(ctx context.Context, client client.Client, log logr.Logger, cluster *anywherev1.Cluster) (controller.Result, error) { - if features.IsActive(features.ExperimentalSelfManagedClusterUpgrade()) { - kcp, err := controller.GetKubeadmControlPlane(ctx, client, cluster) - if err != nil { - return controller.Result{}, err - } - - if kcp == nil { - log.Info("KCP does not exist yet, requeuing") - return controller.ResultWithRequeue(5 * time.Second), nil - } - - // We make sure to check that the status is up to date before using it - if kcp.Status.ObservedGeneration != kcp.ObjectMeta.Generation { - log.Info("KCP information is outdated, requeing") - return controller.ResultWithRequeue(5 * time.Second), nil - } - - if !conditions.IsTrue(kcp, clusterapi.ReadyCondition) { - log.Info("KCP is not ready yet, requeing") - return controller.ResultWithRequeue(30 * time.Second), nil - } - - log.Info("KCP is ready") - return controller.Result{}, nil - } - - capiCluster, err := controller.GetCAPICluster(ctx, client, cluster) + kcp, err := controller.GetKubeadmControlPlane(ctx, client, cluster) if err != nil { return controller.Result{}, err } - if capiCluster == nil { - log.Info("CAPI cluster does not exist yet, requeuing") + if kcp == nil { + log.Info("KCP does not exist yet, requeuing") + return controller.ResultWithRequeue(5 * time.Second), nil + } + + // We make sure to check that the status is up to date before using it + if kcp.Status.ObservedGeneration != kcp.ObjectMeta.Generation { + log.Info("KCP information is outdated, requeing") return controller.ResultWithRequeue(5 * time.Second), nil } - if !conditions.IsTrue(capiCluster, clusterapi.ControlPlaneReadyCondition) { - log.Info("CAPI control plane is not ready yet, requeuing") - // TODO: eventually this can be implemented with controller watches + if !conditions.IsTrue(kcp, clusterapi.ReadyCondition) { + log.Info("KCP is not ready yet, requeing") return controller.ResultWithRequeue(30 * time.Second), nil } - log.Info("CAPI control plane is ready") + log.Info("KCP is ready") return controller.Result{}, nil } diff --git a/pkg/controller/clusters/clusterapi_test.go b/pkg/controller/clusters/clusterapi_test.go index f59d2c65bbd3..ae5461dce9c2 100644 --- a/pkg/controller/clusters/clusterapi_test.go +++ b/pkg/controller/clusters/clusterapi_test.go @@ -2,14 +2,12 @@ package clusters_test import ( "context" - "os" "testing" "time" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta1" controllerruntime "sigs.k8s.io/controller-runtime" @@ -22,74 +20,9 @@ import ( "github.com/aws/eks-anywhere/pkg/constants" "github.com/aws/eks-anywhere/pkg/controller" "github.com/aws/eks-anywhere/pkg/controller/clusters" - "github.com/aws/eks-anywhere/pkg/features" ) func TestCheckControlPlaneReadyItIsReady(t *testing.T) { - g := NewWithT(t) - ctx := context.Background() - eksaCluster := eksaCluster() - capiCluster := capiCluster(func(c *clusterv1.Cluster) { - c.Status.Conditions = clusterv1.Conditions{ - { - Type: clusterapi.ControlPlaneReadyCondition, - Status: corev1.ConditionTrue, - }, - } - }) - - client := fake.NewClientBuilder().WithObjects(eksaCluster, capiCluster).Build() - - result, err := clusters.CheckControlPlaneReady(ctx, client, test.NewNullLogger(), eksaCluster) - g.Expect(err).NotTo(HaveOccurred()) - g.Expect(result).To(Equal(controller.Result{})) -} - -func TestCheckControlPlaneReadyNoCluster(t *testing.T) { - g := NewWithT(t) - ctx := context.Background() - eksaCluster := eksaCluster() - - client := fake.NewClientBuilder().WithObjects(eksaCluster).Build() - - result, err := clusters.CheckControlPlaneReady(ctx, client, test.NewNullLogger(), eksaCluster) - g.Expect(err).NotTo(HaveOccurred()) - g.Expect(result).To(Equal( - controller.Result{Result: &controllerruntime.Result{RequeueAfter: 5 * time.Second}}), - ) -} - -func TestCheckControlPlaneReadyNotReady(t *testing.T) { - g := NewWithT(t) - ctx := context.Background() - eksaCluster := eksaCluster() - capiCluster := capiCluster() - - client := fake.NewClientBuilder().WithObjects(eksaCluster, capiCluster).Build() - - result, err := clusters.CheckControlPlaneReady(ctx, client, test.NewNullLogger(), eksaCluster) - g.Expect(err).NotTo(HaveOccurred()) - g.Expect(result).To(Equal( - controller.Result{Result: &controllerruntime.Result{RequeueAfter: 30 * time.Second}}), - ) -} - -func TestCheckControlPlaneReadyErrorReading(t *testing.T) { - g := NewWithT(t) - ctx := context.Background() - eksaCluster := eksaCluster() - - // This should make the client fail because CRDs are not registered - client := fake.NewClientBuilder().WithScheme(runtime.NewScheme()).Build() - - _, err := clusters.CheckControlPlaneReady(ctx, client, test.NewNullLogger(), eksaCluster) - g.Expect(err).To(MatchError(ContainSubstring("no kind is registered for the type"))) -} - -func TestCheckControlPlaneReadyItIsReadyWithKindlessUpgrade(t *testing.T) { - features.ClearCache() - os.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "true") - g := NewWithT(t) ctx := context.Background() eksaCluster := eksaCluster() @@ -109,10 +42,7 @@ func TestCheckControlPlaneReadyItIsReadyWithKindlessUpgrade(t *testing.T) { g.Expect(result).To(Equal(controller.Result{})) } -func TestCheckControlPlaneReadyNoKcpWithKindlessUpgrade(t *testing.T) { - features.ClearCache() - os.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "true") - +func TestCheckControlPlaneReadyNoKcp(t *testing.T) { g := NewWithT(t) ctx := context.Background() eksaCluster := eksaCluster() @@ -125,10 +55,7 @@ func TestCheckControlPlaneReadyNoKcpWithKindlessUpgrade(t *testing.T) { ) } -func TestCheckControlPlaneNotReadyWithKindlessUpgrade(t *testing.T) { - features.ClearCache() - os.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "true") - +func TestCheckControlPlaneNotReady(t *testing.T) { g := NewWithT(t) ctx := context.Background() eksaCluster := eksaCluster() @@ -147,10 +74,7 @@ func TestCheckControlPlaneNotReadyWithKindlessUpgrade(t *testing.T) { ) } -func TestCheckControlPlaneStatusNotReadyWithKindlessUpgrade(t *testing.T) { - features.ClearCache() - os.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "true") - +func TestCheckControlPlaneStatusNotReady(t *testing.T) { g := NewWithT(t) ctx := context.Background() eksaCluster := eksaCluster() @@ -184,26 +108,6 @@ func eksaCluster() *anywherev1.Cluster { } } -type capiClusterOpt func(*clusterv1.Cluster) - -func capiCluster(opts ...capiClusterOpt) *clusterv1.Cluster { - c := &clusterv1.Cluster{ - TypeMeta: metav1.TypeMeta{ - Kind: "Cluster", - APIVersion: clusterv1.GroupVersion.String(), - }, - ObjectMeta: metav1.ObjectMeta{ - Name: "my-cluster", - Namespace: constants.EksaSystemNamespace, - }, - } - for _, opt := range opts { - opt(c) - } - - return c -} - type kcpObjectOpt func(*v1beta1.KubeadmControlPlane) func kcpObject(opts ...kcpObjectOpt) *v1beta1.KubeadmControlPlane { diff --git a/pkg/features/features.go b/pkg/features/features.go index ed47a79c6bae..479ad7cf8b8f 100644 --- a/pkg/features/features.go +++ b/pkg/features/features.go @@ -5,9 +5,6 @@ const ( CloudStackKubeVipDisabledEnvVar = "CLOUDSTACK_KUBE_VIP_DISABLED" CheckpointEnabledEnvVar = "CHECKPOINT_ENABLED" UseNewWorkflowsEnvVar = "USE_NEW_WORKFLOWS" - - ExperimentalSelfManagedClusterUpgradeEnvVar = "EXP_SELF_MANAGED_API_UPGRADE" - ExperimentalSelfManagedClusterUpgradeGate = "ExpSelfManagedAPIUpgrade" ) func FeedGates(featureGates []string) { @@ -28,17 +25,6 @@ func ClearCache() { globalFeatures.clearCache() } -// ExperimentalSelfManagedClusterUpgrade allows self managed cluster upgrades through the API. -func ExperimentalSelfManagedClusterUpgrade() Feature { - return Feature{ - Name: "[EXPERIMENTAL] Upgrade self-managed clusters through the API", - IsActive: globalFeatures.isActiveForEnvVarOrGate( - ExperimentalSelfManagedClusterUpgradeEnvVar, - ExperimentalSelfManagedClusterUpgradeGate, - ), - } -} - func CloudStackKubeVipDisabled() Feature { return Feature{ Name: "Kube-vip support disabled in CloudStack provider", diff --git a/pkg/providers/cloudstack/reconciler/reconciler_test.go b/pkg/providers/cloudstack/reconciler/reconciler_test.go index fd2eeb2124f6..105309ae5920 100644 --- a/pkg/providers/cloudstack/reconciler/reconciler_test.go +++ b/pkg/providers/cloudstack/reconciler/reconciler_test.go @@ -2,7 +2,9 @@ package reconciler_test import ( "context" + "fmt" "math" + "strings" "testing" "time" @@ -44,10 +46,27 @@ func TestReconcilerReconcileSuccess(t *testing.T) { // We want to check that the cluster status is cleaned up if validations are passed tt.cluster.SetFailure(anywherev1.FailureReasonType("InvalidCluster"), "invalid cluster") - capiCluster := test.CAPICluster(func(c *clusterv1.Cluster) { - c.Name = tt.cluster.Name + kcp := test.KubeadmControlPlane(func(kcp *controlplanev1.KubeadmControlPlane) { + kcp.Name = tt.cluster.Name + kcp.Spec = controlplanev1.KubeadmControlPlaneSpec{ + MachineTemplate: controlplanev1.KubeadmControlPlaneMachineTemplate{ + InfrastructureRef: corev1.ObjectReference{ + Name: fmt.Sprintf("%s-control-plane-1", tt.cluster.Name), + }, + }, + } + kcp.Status = controlplanev1.KubeadmControlPlaneStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterapi.ReadyCondition, + Status: corev1.ConditionTrue, + LastTransitionTime: metav1.NewTime(time.Now()), + }, + }, + ObservedGeneration: 2, + } }) - tt.eksaSupportObjs = append(tt.eksaSupportObjs, capiCluster, tt.secret) + tt.eksaSupportObjs = append(tt.eksaSupportObjs, tt.secret, kcp) tt.createAllObjs() logger := test.NewNullLogger() @@ -56,7 +75,7 @@ func TestReconcilerReconcileSuccess(t *testing.T) { spec := tt.buildSpec() tt.ipValidator.EXPECT().ValidateControlPlaneIP(tt.ctx, logger, tt.buildSpec()).Return(controller.Result{}, nil) tt.remoteClientRegistry.EXPECT().GetClient( - tt.ctx, client.ObjectKey{Name: "workload-cluster", Namespace: constants.EksaSystemNamespace}, + tt.ctx, client.ObjectKey{Name: tt.cluster.Name, Namespace: constants.EksaSystemNamespace}, ).Return(remoteClient, nil).Times(1) tt.cniReconciler.EXPECT().Reconcile(tt.ctx, logger, remoteClient, spec) @@ -87,16 +106,12 @@ func TestReconcilerValidateDatacenterConfigRequeue(t *testing.T) { tt := newReconcilerTest(t) tt.datacenterConfig.Status.SpecValid = false - capiCluster := test.CAPICluster(func(c *clusterv1.Cluster) { - c.Name = tt.cluster.Name - }) - tt.eksaSupportObjs = append(tt.eksaSupportObjs, capiCluster, tt.secret) + tt.eksaSupportObjs = append(tt.eksaSupportObjs, tt.secret) tt.createAllObjs() logger := test.NewNullLogger() tt.ipValidator.EXPECT().ValidateControlPlaneIP(tt.ctx, logger, tt.buildSpec()).Return(controller.Result{}, nil) - result, err := tt.reconciler().Reconcile(tt.ctx, logger, tt.cluster) tt.Expect(err).NotTo(HaveOccurred()) tt.Expect(result).To(Equal(controller.ResultWithReturn())) @@ -108,10 +123,7 @@ func TestReconcilerValidateDatacenterConfigFail(t *testing.T) { tt.datacenterConfig.Status.SpecValid = false tt.datacenterConfig.Status.FailureMessage = ptr.String("Invalid CloudStackDatacenterConfig") - capiCluster := test.CAPICluster(func(c *clusterv1.Cluster) { - c.Name = tt.cluster.Name - }) - tt.eksaSupportObjs = append(tt.eksaSupportObjs, capiCluster, tt.secret) + tt.eksaSupportObjs = append(tt.eksaSupportObjs, tt.secret) tt.createAllObjs() logger := test.NewNullLogger() @@ -182,17 +194,27 @@ func TestReconcilerValidateMachineConfigFail(t *testing.T) { func TestReconcilerControlPlaneIsNotReady(t *testing.T) { tt := newReconcilerTest(t) - capiCluster := test.CAPICluster(func(c *clusterv1.Cluster) { - c.Name = tt.cluster.Name + kcp := test.KubeadmControlPlane(func(kcp *controlplanev1.KubeadmControlPlane) { + kcp.Name = tt.cluster.Name + kcp.Spec = controlplanev1.KubeadmControlPlaneSpec{ + MachineTemplate: controlplanev1.KubeadmControlPlaneMachineTemplate{ + InfrastructureRef: corev1.ObjectReference{ + Name: fmt.Sprintf("%s-control-plane-1", tt.cluster.Name), + }, + }, + } + kcp.Status = controlplanev1.KubeadmControlPlaneStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterapi.ReadyCondition, + Status: corev1.ConditionFalse, + LastTransitionTime: metav1.NewTime(time.Now()), + }, + }, + ObservedGeneration: 2, + } }) - capiCluster.Status.Conditions = clusterv1.Conditions{ - { - Type: clusterapi.ControlPlaneReadyCondition, - Status: corev1.ConditionFalse, - LastTransitionTime: metav1.NewTime(time.Now()), - }, - } - tt.eksaSupportObjs = append(tt.eksaSupportObjs, capiCluster, tt.secret) + tt.eksaSupportObjs = append(tt.eksaSupportObjs, kcp, tt.secret) tt.createAllObjs() logger := test.NewNullLogger() @@ -230,11 +252,6 @@ func TestReconcileControlPlaneUnstackedEtcdSuccess(t *testing.T) { tt.Expect(tt.cluster.Status.FailureReason).To(BeZero()) tt.Expect(result).To(Equal(controller.Result{})) - capiCluster := test.CAPICluster(func(c *clusterv1.Cluster) { - c.Name = tt.cluster.Name - }) - - tt.ShouldEventuallyExist(tt.ctx, capiCluster) tt.ShouldEventuallyExist(tt.ctx, &cloudstackv1.CloudStackCluster{ ObjectMeta: metav1.ObjectMeta{ Name: tt.cluster.Name, @@ -342,7 +359,7 @@ func TestReconcileCNISuccess(t *testing.T) { spec := tt.buildSpec() tt.remoteClientRegistry.EXPECT().GetClient( - tt.ctx, client.ObjectKey{Name: "workload-cluster", Namespace: "eksa-system"}, + tt.ctx, client.ObjectKey{Name: tt.cluster.Name, Namespace: "eksa-system"}, ).Return(remoteClient, nil) tt.cniReconciler.EXPECT().Reconcile(tt.ctx, logger, remoteClient, spec) @@ -363,7 +380,7 @@ func TestReconcileCNIErrorClientRegistry(t *testing.T) { spec := tt.buildSpec() tt.remoteClientRegistry.EXPECT().GetClient( - tt.ctx, client.ObjectKey{Name: "workload-cluster", Namespace: "eksa-system"}, + tt.ctx, client.ObjectKey{Name: tt.cluster.Name, Namespace: "eksa-system"}, ).Return(nil, errors.New("building client")) result, err := tt.reconciler().ReconcileCNI(tt.ctx, logger, spec) @@ -615,7 +632,7 @@ func newReconcilerTest(t testing.TB) *reconcilerTest { }) cluster := cloudstackCluster(func(c *anywherev1.Cluster) { - c.Name = "workload-cluster" + c.Name = strings.ToLower(t.Name()) c.Spec.ManagementCluster = anywherev1.ManagementCluster{ Name: managementCluster.Name, } @@ -709,13 +726,13 @@ func (tt *reconcilerTest) cleanup() { tt.DeleteAllOfAndWait(tt.ctx, &controlplanev1.KubeadmControlPlane{}) tt.DeleteAndWait(tt.ctx, &cloudstackv1.CloudStackMachineTemplate{ ObjectMeta: metav1.ObjectMeta{ - Name: "workload-cluster-etcd-1", + Name: tt.cluster.Name + "-etcd-1", Namespace: "eksa-system", }, }) tt.DeleteAndWait(tt.ctx, &etcdv1.EtcdadmCluster{ ObjectMeta: metav1.ObjectMeta{ - Name: "workload-cluster-etcd", + Name: tt.cluster.Name + "-etcd", Namespace: "eksa-system", }, }) diff --git a/pkg/providers/docker/reconciler/reconciler_test.go b/pkg/providers/docker/reconciler/reconciler_test.go index 9850c2c9a1fd..c53bce394b9b 100644 --- a/pkg/providers/docker/reconciler/reconciler_test.go +++ b/pkg/providers/docker/reconciler/reconciler_test.go @@ -3,12 +3,15 @@ package reconciler_test import ( "context" "errors" + "fmt" "strings" "testing" + "time" etcdv1 "github.com/aws/etcdadm-controller/api/v1beta1" "github.com/golang/mock/gomock" . "github.com/onsi/gomega" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" @@ -22,6 +25,7 @@ import ( "github.com/aws/eks-anywhere/internal/test/envtest" anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1" clusterspec "github.com/aws/eks-anywhere/pkg/cluster" + "github.com/aws/eks-anywhere/pkg/clusterapi" "github.com/aws/eks-anywhere/pkg/constants" "github.com/aws/eks-anywhere/pkg/controller" "github.com/aws/eks-anywhere/pkg/controller/clientutil" @@ -37,10 +41,27 @@ const ( func TestReconcilerReconcileSuccess(t *testing.T) { tt := newReconcilerTest(t) logger := test.NewNullLogger() - capiCluster := test.CAPICluster(func(c *clusterv1.Cluster) { - c.Name = tt.cluster.Name + kcp := test.KubeadmControlPlane(func(kcp *controlplanev1.KubeadmControlPlane) { + kcp.Name = tt.cluster.Name + kcp.Spec = controlplanev1.KubeadmControlPlaneSpec{ + MachineTemplate: controlplanev1.KubeadmControlPlaneMachineTemplate{ + InfrastructureRef: corev1.ObjectReference{ + Name: fmt.Sprintf("%s-control-plane-1", tt.cluster.Name), + }, + }, + } + kcp.Status = controlplanev1.KubeadmControlPlaneStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterapi.ReadyCondition, + Status: corev1.ConditionTrue, + LastTransitionTime: metav1.NewTime(time.Now()), + }, + }, + ObservedGeneration: 2, + } }) - tt.eksaSupportObjs = append(tt.eksaSupportObjs, capiCluster) + tt.eksaSupportObjs = append(tt.eksaSupportObjs, kcp) tt.createAllObjs() remoteClient := fake.NewClientBuilder().Build() @@ -53,7 +74,7 @@ func TestReconcilerReconcileSuccess(t *testing.T) { tt.Expect(tt.cluster.Status.FailureMessage).To(BeZero()) tt.Expect(tt.cluster.Status.FailureReason).To(BeZero()) - tt.ShouldEventuallyExist(tt.ctx, capiCluster) + tt.ShouldEventuallyExist(tt.ctx, kcp) tt.ShouldEventuallyExist(tt.ctx, &controlplanev1.KubeadmControlPlane{ ObjectMeta: metav1.ObjectMeta{ @@ -356,11 +377,6 @@ func TestReconcileControlPlaneUnstackedEtcdSuccess(t *testing.T) { tt.Expect(tt.cluster.Status.FailureReason).To(BeZero()) tt.Expect(result).To(Equal(controller.Result{})) - capiCluster := test.CAPICluster(func(c *clusterv1.Cluster) { - c.Name = tt.cluster.Name - }) - - tt.ShouldEventuallyExist(tt.ctx, capiCluster) tt.ShouldEventuallyExist(tt.ctx, &controlplanev1.KubeadmControlPlane{ ObjectMeta: metav1.ObjectMeta{ diff --git a/pkg/providers/snow/reconciler/reconciler_test.go b/pkg/providers/snow/reconciler/reconciler_test.go index 082cfe60b858..ad6a271da783 100644 --- a/pkg/providers/snow/reconciler/reconciler_test.go +++ b/pkg/providers/snow/reconciler/reconciler_test.go @@ -2,7 +2,10 @@ package reconciler_test import ( "context" + "fmt" + "strings" "testing" + "time" "github.com/golang/mock/gomock" . "github.com/onsi/gomega" @@ -20,6 +23,7 @@ import ( "github.com/aws/eks-anywhere/internal/test/envtest" anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1" clusterspec "github.com/aws/eks-anywhere/pkg/cluster" + "github.com/aws/eks-anywhere/pkg/clusterapi" "github.com/aws/eks-anywhere/pkg/constants" "github.com/aws/eks-anywhere/pkg/controller" "github.com/aws/eks-anywhere/pkg/controller/clientutil" @@ -37,10 +41,27 @@ func TestReconcilerReconcileSuccess(t *testing.T) { tt := newReconcilerTest(t) // We want to check that the cluster status is cleaned up if validations are passed tt.cluster.SetFailure(anywherev1.FailureReasonType("InvalidCluster"), "invalid cluster") - capiCluster := test.CAPICluster(func(c *clusterv1.Cluster) { - c.Name = tt.cluster.Name + kcp := test.KubeadmControlPlane(func(kcp *controlplanev1.KubeadmControlPlane) { + kcp.Name = tt.cluster.Name + kcp.Spec = controlplanev1.KubeadmControlPlaneSpec{ + MachineTemplate: controlplanev1.KubeadmControlPlaneMachineTemplate{ + InfrastructureRef: corev1.ObjectReference{ + Name: fmt.Sprintf("%s-control-plane-1", tt.cluster.Name), + }, + }, + } + kcp.Status = controlplanev1.KubeadmControlPlaneStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterapi.ReadyCondition, + Status: corev1.ConditionTrue, + LastTransitionTime: metav1.NewTime(time.Now()), + }, + }, + ObservedGeneration: 2, + } }) - tt.eksaSupportObjs = append(tt.eksaSupportObjs, capiCluster) + tt.eksaSupportObjs = append(tt.eksaSupportObjs, kcp) tt.createAllObjs() logger := test.NewNullLogger() @@ -49,7 +70,7 @@ func TestReconcilerReconcileSuccess(t *testing.T) { tt.ipValidator.EXPECT().ValidateControlPlaneIP(tt.ctx, logger, tt.buildSpec()).Return(controller.Result{}, nil) tt.remoteClientRegistry.EXPECT().GetClient( - tt.ctx, client.ObjectKey{Name: "workload-cluster", Namespace: "eksa-system"}, + tt.ctx, client.ObjectKey{Name: tt.cluster.Name, Namespace: "eksa-system"}, ).Return(remoteClient, nil) tt.cniReconciler.EXPECT().Reconcile(tt.ctx, logger, remoteClient, tt.buildSpec()) @@ -174,6 +195,7 @@ func TestReconcilerReconcileWorkers(t *testing.T) { c.Name = tt.cluster.Name }) tt.eksaSupportObjs = append(tt.eksaSupportObjs, capiCluster) + tt.createAllObjs() result, err := tt.reconciler().ReconcileWorkers(tt.ctx, test.NewNullLogger(), tt.buildSpec()) @@ -198,7 +220,7 @@ func TestReconcilerReconcileControlPlane(t *testing.T) { tt.ShouldEventuallyExist(tt.ctx, &controlplanev1.KubeadmControlPlane{ ObjectMeta: metav1.ObjectMeta{ - Name: "workload-cluster", + Name: tt.cluster.Name, Namespace: "eksa-system", }, }, @@ -207,26 +229,42 @@ func TestReconcilerReconcileControlPlane(t *testing.T) { tt.ShouldEventuallyExist(tt.ctx, &snowv1.AWSSnowMachineTemplate{ ObjectMeta: metav1.ObjectMeta{ - Name: "workload-cluster-control-plane-1", + Name: tt.cluster.Name + "-control-plane-1", Namespace: "eksa-system", }, }, ) capiCluster := test.CAPICluster(func(c *clusterv1.Cluster) { - c.Name = "workload-cluster" + c.Name = tt.cluster.Name }) tt.ShouldEventuallyExist(tt.ctx, capiCluster) - tt.ShouldEventuallyExist(tt.ctx, &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "workload-cluster-snow-credentials", Namespace: "eksa-system"}}) + tt.ShouldEventuallyExist(tt.ctx, &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: tt.cluster.Name + "-snow-credentials", Namespace: "eksa-system"}}) } func TestReconcilerCheckControlPlaneReadyItIsReady(t *testing.T) { tt := newReconcilerTest(t) - capiCluster := test.CAPICluster(func(c *clusterv1.Cluster) { - c.Name = tt.cluster.Name + kcp := test.KubeadmControlPlane(func(kcp *controlplanev1.KubeadmControlPlane) { + kcp.Name = tt.cluster.Name + kcp.Spec = controlplanev1.KubeadmControlPlaneSpec{ + MachineTemplate: controlplanev1.KubeadmControlPlaneMachineTemplate{ + InfrastructureRef: corev1.ObjectReference{ + Name: fmt.Sprintf("%s-control-plane-1", tt.cluster.Name), + }, + }, + } + kcp.Status = controlplanev1.KubeadmControlPlaneStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterapi.ReadyCondition, + Status: corev1.ConditionTrue, + LastTransitionTime: metav1.NewTime(time.Now()), + }, + }, + } }) - tt.eksaSupportObjs = append(tt.eksaSupportObjs, capiCluster) + tt.eksaSupportObjs = append(tt.eksaSupportObjs, kcp) tt.withFakeClient() result, err := tt.reconciler().CheckControlPlaneReady(tt.ctx, test.NewNullLogger(), tt.buildSpec()) @@ -246,7 +284,7 @@ func TestReconcilerReconcileCNISuccess(t *testing.T) { spec := tt.buildSpec() tt.remoteClientRegistry.EXPECT().GetClient( - tt.ctx, client.ObjectKey{Name: "workload-cluster", Namespace: "eksa-system"}, + tt.ctx, client.ObjectKey{Name: tt.cluster.Name, Namespace: "eksa-system"}, ).Return(remoteClient, nil) tt.cniReconciler.EXPECT().Reconcile(tt.ctx, logger, remoteClient, spec) @@ -266,7 +304,7 @@ func TestReconcilerReconcileCNIErrorClientRegistry(t *testing.T) { spec := tt.buildSpec() tt.remoteClientRegistry.EXPECT().GetClient( - tt.ctx, client.ObjectKey{Name: "workload-cluster", Namespace: "eksa-system"}, + tt.ctx, client.ObjectKey{Name: tt.cluster.Name, Namespace: "eksa-system"}, ).Return(nil, errors.New("building client")) result, err := tt.reconciler().ReconcileCNI(tt.ctx, logger, spec) @@ -341,7 +379,7 @@ func newReconcilerTest(t testing.TB) *reconcilerTest { }) cluster := snowCluster(func(c *anywherev1.Cluster) { - c.Name = "workload-cluster" + c.Name = strings.ToLower(t.Name()) c.Spec.ManagementCluster = anywherev1.ManagementCluster{ Name: managementCluster.Name, } diff --git a/pkg/providers/tinkerbell/reconciler/reconciler_test.go b/pkg/providers/tinkerbell/reconciler/reconciler_test.go index 6c6e94ac18d6..f605b5ff30d8 100644 --- a/pkg/providers/tinkerbell/reconciler/reconciler_test.go +++ b/pkg/providers/tinkerbell/reconciler/reconciler_test.go @@ -3,7 +3,9 @@ package reconciler_test import ( "context" "errors" + "fmt" "testing" + "time" "github.com/golang/mock/gomock" . "github.com/onsi/gomega" @@ -59,7 +61,29 @@ func TestReconcilerReconcileSuccess(t *testing.T) { capiCluster := test.CAPICluster(func(c *clusterv1.Cluster) { c.Name = tt.cluster.Name }) - tt.eksaSupportObjs = append(tt.eksaSupportObjs, capiCluster) + kcp := test.KubeadmControlPlane(func(kcp *controlplanev1.KubeadmControlPlane) { + kcp.Name = tt.cluster.Name + kcp.Spec = controlplanev1.KubeadmControlPlaneSpec{ + MachineTemplate: controlplanev1.KubeadmControlPlaneMachineTemplate{ + InfrastructureRef: corev1.ObjectReference{ + Name: fmt.Sprintf("%s-control-plane-1", tt.cluster.Name), + }, + }, + Version: "v1.19.8", + Replicas: ptr.Int32(1), + } + kcp.Status = controlplanev1.KubeadmControlPlaneStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterapi.ReadyCondition, + Status: corev1.ConditionTrue, + LastTransitionTime: metav1.NewTime(time.Now()), + }, + }, + ObservedGeneration: 2, + } + }) + tt.eksaSupportObjs = append(tt.eksaSupportObjs, capiCluster, kcp) tt.eksaSupportObjs = append(tt.eksaSupportObjs, tinkHardware("hw1", "cp")) tt.eksaSupportObjs = append(tt.eksaSupportObjs, tinkHardware("hw2", "worker")) tt.createAllObjs() diff --git a/pkg/providers/vsphere/reconciler/reconciler_test.go b/pkg/providers/vsphere/reconciler/reconciler_test.go index ef97ac76c122..b4d992dadb4f 100644 --- a/pkg/providers/vsphere/reconciler/reconciler_test.go +++ b/pkg/providers/vsphere/reconciler/reconciler_test.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "os" + "strings" "testing" "time" @@ -49,10 +50,27 @@ func TestReconcilerReconcileSuccess(t *testing.T) { // We want to check that the cluster status is cleaned up if validations are passed tt.cluster.SetFailure(anywherev1.FailureReasonType("InvalidCluster"), "invalid cluster") - capiCluster := test.CAPICluster(func(c *clusterv1.Cluster) { - c.Name = tt.cluster.Name + kcp := test.KubeadmControlPlane(func(kcp *controlplanev1.KubeadmControlPlane) { + kcp.Name = tt.cluster.Name + kcp.Spec = controlplanev1.KubeadmControlPlaneSpec{ + MachineTemplate: controlplanev1.KubeadmControlPlaneMachineTemplate{ + InfrastructureRef: corev1.ObjectReference{ + Name: fmt.Sprintf("%s-control-plane-1", tt.cluster.Name), + }, + }, + } + kcp.Status = controlplanev1.KubeadmControlPlaneStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterapi.ReadyCondition, + Status: corev1.ConditionTrue, + LastTransitionTime: metav1.NewTime(time.Now()), + }, + }, + ObservedGeneration: 2, + } }) - tt.eksaSupportObjs = append(tt.eksaSupportObjs, capiCluster) + tt.eksaSupportObjs = append(tt.eksaSupportObjs, kcp) tt.createAllObjs() logger := test.NewNullLogger() @@ -66,7 +84,7 @@ func TestReconcilerReconcileSuccess(t *testing.T) { tt.govcClient.EXPECT().ListTags(tt.ctx).Return([]executables.Tag{}, nil) tt.remoteClientRegistry.EXPECT().GetClient( - tt.ctx, client.ObjectKey{Name: "workload-cluster", Namespace: "eksa-system"}, + tt.ctx, client.ObjectKey{Name: tt.cluster.Name, Namespace: "eksa-system"}, ).Return(remoteClient, nil).Times(1) tt.cniReconciler.EXPECT().Reconcile(tt.ctx, logger, remoteClient, tt.buildSpec()) @@ -167,17 +185,28 @@ func TestSetupEnvVars(t *testing.T) { func TestReconcilerControlPlaneIsNotReady(t *testing.T) { tt := newReconcilerTest(t) - capiCluster := test.CAPICluster(func(c *clusterv1.Cluster) { - c.Name = tt.cluster.Name + kcp := test.KubeadmControlPlane(func(kcp *controlplanev1.KubeadmControlPlane) { + kcp.Name = tt.cluster.Name + kcp.Spec = controlplanev1.KubeadmControlPlaneSpec{ + MachineTemplate: controlplanev1.KubeadmControlPlaneMachineTemplate{ + InfrastructureRef: corev1.ObjectReference{ + Name: fmt.Sprintf("%s-control-plane-1", tt.cluster.Name), + }, + }, + } + kcp.Status = controlplanev1.KubeadmControlPlaneStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterapi.ReadyCondition, + Status: corev1.ConditionFalse, + LastTransitionTime: metav1.NewTime(time.Now()), + }, + }, + ObservedGeneration: 2, + } }) - capiCluster.Status.Conditions = clusterv1.Conditions{ - { - Type: clusterapi.ControlPlaneReadyCondition, - Status: corev1.ConditionFalse, - LastTransitionTime: metav1.NewTime(time.Now()), - }, - } - tt.eksaSupportObjs = append(tt.eksaSupportObjs, capiCluster) + + tt.eksaSupportObjs = append(tt.eksaSupportObjs, kcp) tt.createAllObjs() logger := test.NewNullLogger() @@ -199,10 +228,9 @@ func TestReconcilerControlPlaneIsNotReady(t *testing.T) { func TestReconcilerReconcileWorkersSuccess(t *testing.T) { tt := newReconcilerTest(t) - capiCluster := test.CAPICluster(func(c *clusterv1.Cluster) { + tt.eksaSupportObjs = append(tt.eksaSupportObjs, test.CAPICluster(func(c *clusterv1.Cluster) { c.Name = tt.cluster.Name - }) - tt.eksaSupportObjs = append(tt.eksaSupportObjs, capiCluster) + })) tt.createAllObjs() result, err := tt.reconciler().ReconcileWorkers(tt.ctx, test.NewNullLogger(), tt.buildSpec()) @@ -252,7 +280,7 @@ func TestReconcileCNISuccess(t *testing.T) { spec := tt.buildSpec() tt.remoteClientRegistry.EXPECT().GetClient( - tt.ctx, client.ObjectKey{Name: "workload-cluster", Namespace: "eksa-system"}, + tt.ctx, client.ObjectKey{Name: tt.cluster.Name, Namespace: "eksa-system"}, ).Return(remoteClient, nil) tt.cniReconciler.EXPECT().Reconcile(tt.ctx, logger, remoteClient, spec) @@ -272,7 +300,7 @@ func TestReconcileCNIErrorClientRegistry(t *testing.T) { spec := tt.buildSpec() tt.remoteClientRegistry.EXPECT().GetClient( - tt.ctx, client.ObjectKey{Name: "workload-cluster", Namespace: "eksa-system"}, + tt.ctx, client.ObjectKey{Name: tt.cluster.Name, Namespace: "eksa-system"}, ).Return(nil, errors.New("building client")) result, err := tt.reconciler().ReconcileCNI(tt.ctx, logger, spec) @@ -297,7 +325,7 @@ func TestReconcilerReconcileControlPlaneSuccess(t *testing.T) { tt.ShouldEventuallyExist(tt.ctx, &addonsv1.ClusterResourceSet{ ObjectMeta: metav1.ObjectMeta{ - Name: "workload-cluster-cpi", + Name: tt.cluster.Name + "-cpi", Namespace: "eksa-system", }, }, @@ -306,7 +334,7 @@ func TestReconcilerReconcileControlPlaneSuccess(t *testing.T) { tt.ShouldEventuallyExist(tt.ctx, &controlplanev1.KubeadmControlPlane{ ObjectMeta: metav1.ObjectMeta{ - Name: "workload-cluster", + Name: tt.cluster.Name, Namespace: "eksa-system", }, }, @@ -315,20 +343,20 @@ func TestReconcilerReconcileControlPlaneSuccess(t *testing.T) { tt.ShouldEventuallyExist(tt.ctx, &vspherev1.VSphereMachineTemplate{ ObjectMeta: metav1.ObjectMeta{ - Name: "workload-cluster-control-plane-1", + Name: tt.cluster.Name + "-control-plane-1", Namespace: "eksa-system", }, }, ) capiCluster := test.CAPICluster(func(c *clusterv1.Cluster) { - c.Name = "workload-cluster" + c.Name = tt.cluster.Name }) tt.ShouldEventuallyExist(tt.ctx, capiCluster) - tt.ShouldEventuallyExist(tt.ctx, &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "workload-cluster-cloud-controller-manager", Namespace: "eksa-system"}}) - tt.ShouldEventuallyExist(tt.ctx, &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "workload-cluster-cloud-provider-vsphere-credentials", Namespace: "eksa-system"}}) - tt.ShouldEventuallyExist(tt.ctx, &corev1.ConfigMap{ObjectMeta: metav1.ObjectMeta{Name: "workload-cluster-cpi-manifests", Namespace: "eksa-system"}}) + tt.ShouldEventuallyExist(tt.ctx, &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: tt.cluster.Name + "-cloud-controller-manager", Namespace: "eksa-system"}}) + tt.ShouldEventuallyExist(tt.ctx, &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: tt.cluster.Name + "-cloud-provider-vsphere-credentials", Namespace: "eksa-system"}}) + tt.ShouldEventuallyExist(tt.ctx, &corev1.ConfigMap{ObjectMeta: metav1.ObjectMeta{Name: tt.cluster.Name + "-cpi-manifests", Namespace: "eksa-system"}}) } type reconcilerTest struct { @@ -397,7 +425,7 @@ func newReconcilerTest(t testing.TB) *reconcilerTest { }) cluster := test.Cluster(func(c *anywherev1.Cluster) { - c.Name = "workload-cluster" + c.Name = strings.ToLower(t.Name()) c.Namespace = clusterNamespace c.Spec.ManagementCluster = anywherev1.ManagementCluster{ Name: managementCluster.Name, diff --git a/pkg/workflows/management/upgrade_test.go b/pkg/workflows/management/upgrade_test.go index 1ef038b63d47..367c2409e0b8 100644 --- a/pkg/workflows/management/upgrade_test.go +++ b/pkg/workflows/management/upgrade_test.go @@ -278,7 +278,6 @@ func (c *upgradeManagementTestSetup) expectPreflightValidationsToPass() { func TestUpgradeManagementRunUpdateSetupFailed(t *testing.T) { os.Unsetenv(features.CheckpointEnabledEnvVar) features.ClearCache() - t.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "true") test := newUpgradeManagementClusterTest(t) test.expectSetupToFail() test.expectWriteCheckpointFile() @@ -292,7 +291,6 @@ func TestUpgradeManagementRunUpdateSetupFailed(t *testing.T) { func TestUpgradeManagementRunUpdateSecretFailed(t *testing.T) { os.Unsetenv(features.CheckpointEnabledEnvVar) features.ClearCache() - t.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "true") test := newUpgradeManagementClusterTest(t) test.expectSetup() test.expectPreflightValidationsToPass() @@ -309,7 +307,6 @@ func TestUpgradeManagementRunUpdateSecretFailed(t *testing.T) { func TestUpgradeManagementRunEnsureETCDFailed(t *testing.T) { os.Unsetenv(features.CheckpointEnabledEnvVar) features.ClearCache() - t.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "true") test := newUpgradeManagementClusterTest(t) test.expectSetup() test.expectPreflightValidationsToPass() @@ -327,7 +324,6 @@ func TestUpgradeManagementRunEnsureETCDFailed(t *testing.T) { func TestUpgradeManagementRunPauseGitOpsReconcileUpgradeFailed(t *testing.T) { os.Unsetenv(features.CheckpointEnabledEnvVar) features.ClearCache() - t.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "true") test := newUpgradeManagementClusterTest(t) test.expectSetup() test.expectPreflightValidationsToPass() @@ -346,7 +342,6 @@ func TestUpgradeManagementRunPauseGitOpsReconcileUpgradeFailed(t *testing.T) { func TestUpgradeManagementRunFailedBackup(t *testing.T) { os.Unsetenv(features.CheckpointEnabledEnvVar) features.ClearCache() - t.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "true") test := newUpgradeManagementClusterTest(t) test.expectSetup() test.expectPreflightValidationsToPass() @@ -368,7 +363,6 @@ func TestUpgradeManagementRunFailedBackup(t *testing.T) { func TestUpgradeManagementRunPauseWorkloadCAPIFailed(t *testing.T) { os.Unsetenv(features.CheckpointEnabledEnvVar) features.ClearCache() - t.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "true") test := newUpgradeManagementClusterTest(t) test.expectSetup() test.expectPreflightValidationsToPass() @@ -390,7 +384,6 @@ func TestUpgradeManagementRunPauseWorkloadCAPIFailed(t *testing.T) { func TestUpgradeManagementRunFailedUpgradeInstallEksd(t *testing.T) { os.Unsetenv(features.CheckpointEnabledEnvVar) features.ClearCache() - t.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "true") test := newUpgradeManagementClusterTest(t) test.expectSetup() test.expectPreflightValidationsToPass() @@ -417,7 +410,6 @@ func TestUpgradeManagementRunFailedUpgradeInstallEksd(t *testing.T) { func TestUpgradeManagementRunFailedUpgradeApplyBundles(t *testing.T) { os.Unsetenv(features.CheckpointEnabledEnvVar) features.ClearCache() - t.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "true") test := newUpgradeManagementClusterTest(t) test.expectSetup() test.expectPreflightValidationsToPass() @@ -442,7 +434,6 @@ func TestUpgradeManagementRunFailedUpgradeApplyBundles(t *testing.T) { func TestUpgradeManagementRunFailedUpgradeApplyReleases(t *testing.T) { os.Unsetenv(features.CheckpointEnabledEnvVar) features.ClearCache() - t.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "true") test := newUpgradeManagementClusterTest(t) test.expectSetup() test.expectPreflightValidationsToPass() @@ -468,7 +459,6 @@ func TestUpgradeManagementRunFailedUpgradeApplyReleases(t *testing.T) { func TestUpgradeManagementRunFailedUpgrade(t *testing.T) { os.Unsetenv(features.CheckpointEnabledEnvVar) features.ClearCache() - t.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "true") test := newUpgradeManagementClusterTest(t) test.expectSetup() test.expectPreflightValidationsToPass() @@ -496,7 +486,6 @@ func TestUpgradeManagementRunFailedUpgrade(t *testing.T) { func TestUpgradeManagementRunResumeCAPIWorkloadFailed(t *testing.T) { os.Unsetenv(features.CheckpointEnabledEnvVar) features.ClearCache() - t.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "true") test := newUpgradeManagementClusterTest(t) test.expectSetup() test.expectPreflightValidationsToPass() @@ -529,7 +518,6 @@ func TestUpgradeManagementRunResumeCAPIWorkloadFailed(t *testing.T) { func TestUpgradeManagementRunUpdateGitEksaSpecFailed(t *testing.T) { os.Unsetenv(features.CheckpointEnabledEnvVar) features.ClearCache() - t.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "true") test := newUpgradeManagementClusterTest(t) test.expectSetup() test.expectPreflightValidationsToPass() @@ -558,7 +546,6 @@ func TestUpgradeManagementRunUpdateGitEksaSpecFailed(t *testing.T) { func TestUpgradeManagementRunForceReconcileGitRepoFailed(t *testing.T) { os.Unsetenv(features.CheckpointEnabledEnvVar) features.ClearCache() - t.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "true") test := newUpgradeManagementClusterTest(t) test.expectSetup() test.expectPreflightValidationsToPass() @@ -588,7 +575,6 @@ func TestUpgradeManagementRunForceReconcileGitRepoFailed(t *testing.T) { func TestUpgradeManagementRunResumeClusterResourcesReconcileFailed(t *testing.T) { os.Unsetenv(features.CheckpointEnabledEnvVar) features.ClearCache() - t.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "true") test := newUpgradeManagementClusterTest(t) test.expectSetup() test.expectPreflightValidationsToPass() @@ -620,7 +606,6 @@ func TestUpgradeManagementRunResumeClusterResourcesReconcileFailed(t *testing.T) func TestUpgradeManagementRunSuccess(t *testing.T) { os.Unsetenv(features.CheckpointEnabledEnvVar) features.ClearCache() - t.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "true") test := newUpgradeManagementClusterTest(t) test.expectSetup() test.expectPreflightValidationsToPass() diff --git a/test/framework/cluster.go b/test/framework/cluster.go index 3fc17c477f79..7792863c98dc 100644 --- a/test/framework/cluster.go +++ b/test/framework/cluster.go @@ -35,7 +35,6 @@ import ( "github.com/aws/eks-anywhere/pkg/cluster" "github.com/aws/eks-anywhere/pkg/constants" "github.com/aws/eks-anywhere/pkg/executables" - "github.com/aws/eks-anywhere/pkg/features" "github.com/aws/eks-anywhere/pkg/filewriter" "github.com/aws/eks-anywhere/pkg/git" "github.com/aws/eks-anywhere/pkg/providers/cloudstack/decoder" @@ -121,11 +120,6 @@ func NewClusterE2ETest(t T, provider Provider, opts ...ClusterE2ETestOpt) *Clust eksaBinaryLocation: defaultEksaBinaryLocation, } - // For kindless management upgrade task - // Remove this once we remove feature flag for ExpSelfManagedAPIUpgrade. - opts = append(opts, WithEnvVar(features.ExperimentalSelfManagedClusterUpgradeGate, "true")) - opts = append(opts, WithEnvVar(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "true")) - for _, opt := range opts { opt(e) }