Skip to content

Commit

Permalink
remove kindless upgrade feature flag for all the providers
Browse files Browse the repository at this point in the history
  • Loading branch information
panktishah26 committed Oct 24, 2023
1 parent c359add commit fad5088
Show file tree
Hide file tree
Showing 19 changed files with 237 additions and 394 deletions.
4 changes: 1 addition & 3 deletions cmd/eksctl-anywhere/cmd/upgradecluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -195,8 +194,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,
Expand Down
7 changes: 1 addition & 6 deletions manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down
34 changes: 15 additions & 19 deletions pkg/api/v1alpha1/cluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -374,28 +373,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
}
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
}
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)))
}
return allErrs
if !oldAWSIamConfig.Equal(newAWSIamConfig) {
allErrs = append(
allErrs,
field.Forbidden(specPath.Child("identityProviderRefs", AWSIamConfigKind), fmt.Sprintf("field is immutable %v", newAWSIamConfig.Kind)))
}

clusterlog.Info("Cluster config is associated with management cluster", "name", old.Name)
Expand Down
40 changes: 0 additions & 40 deletions pkg/api/v1alpha1/cluster_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -288,8 +259,6 @@ func TestCloudStackClusterValidateUpdateControlPlaneConfigurationOldPortImmutabl
}

func TestManagementClusterValidateUpdateControlPlaneConfigurationTaintsImmutable(t *testing.T) {
features.ClearCache()
t.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "false")
cOld := baseCluster()
cOld.Spec.ControlPlaneConfiguration = v1alpha1.ControlPlaneConfiguration{
Taints: []v1.Taint{
Expand Down Expand Up @@ -317,8 +286,6 @@ func TestManagementClusterValidateUpdateControlPlaneConfigurationTaintsImmutable
}

func TestManagementClusterValidateUpdateControlPlaneConfigurationLabelsImmutable(t *testing.T) {
features.ClearCache()
t.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "false")
cOld := baseCluster()
cOld.Spec.ControlPlaneConfiguration = v1alpha1.ControlPlaneConfiguration{
Labels: map[string]string{
Expand All @@ -338,8 +305,6 @@ func TestManagementClusterValidateUpdateControlPlaneConfigurationLabelsImmutable
}

func TestManagementClusterValidateUpdateControlPlaneConfigurationOldMachineGroupRefImmutable(t *testing.T) {
features.ClearCache()
t.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "false")
cOld := baseCluster()
cOld.Spec.ControlPlaneConfiguration = v1alpha1.ControlPlaneConfiguration{
MachineGroupRef: &v1alpha1.Ref{Name: "test1", Kind: "MachineConfig"},
Expand Down Expand Up @@ -368,8 +333,6 @@ func TestWorkloadClusterValidateUpdateControlPlaneConfigurationMachineGroupRef(t
}

func TestManagementClusterValidateUpdateControlPlaneConfigurationOldMachineGroupRefNilImmutable(t *testing.T) {
features.ClearCache()
t.Setenv(features.ExperimentalSelfManagedClusterUpgradeEnvVar, "false")
cOld := baseCluster()
cOld.Spec.ControlPlaneConfiguration = v1alpha1.ControlPlaneConfiguration{
MachineGroupRef: nil,
Expand Down Expand Up @@ -398,8 +361,6 @@ 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"},
Expand Down Expand Up @@ -1815,7 +1776,6 @@ func TestClusterValidateUpdateInvalidRequest(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
Expand Down
65 changes: 0 additions & 65 deletions pkg/api/v1alpha1/vspheremachineconfig_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ package v1alpha1

import (
"fmt"
"reflect"

apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field"
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.
Expand Down Expand Up @@ -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
}

Expand Down
Loading

0 comments on commit fad5088

Please sign in to comment.