diff --git a/pkg/types/defaults/machinepools.go b/pkg/types/defaults/machinepools.go index f42aebf6442..6b5ec2124ac 100644 --- a/pkg/types/defaults/machinepools.go +++ b/pkg/types/defaults/machinepools.go @@ -40,18 +40,11 @@ func SetMachinePoolDefaults(p *types.MachinePool, platform *types.Platform, fgat } } - // Set management to ClusterAPI if the appropriate feature gate is enabled and management is unspecified - if p.Management == "" { - if p.Name == types.MachinePoolControlPlaneRoleName && fgates.Enabled(features.FeatureGateClusterAPIControlPlaneInstall) { - p.Management = types.ClusterAPI - } - if p.Name == types.MachinePoolComputeRoleName && fgates.Enabled(features.FeatureGateClusterAPIComputeInstall) { - p.Management = types.ClusterAPI - } - } - switch platform.Name() { case aws.Name: + if p.Management == "" && p.Name == types.MachinePoolComputeRoleName && fgates.Enabled(features.FeatureGateClusterAPIMachineManagementAWS) { + p.Management = types.ClusterAPI + } if p.Platform.AWS == nil && platform.AWS.DefaultMachinePlatform != nil { p.Platform.AWS = &aws.MachinePool{} } diff --git a/pkg/types/defaults/machinepools_test.go b/pkg/types/defaults/machinepools_test.go index 4540c2daaee..b18d6bc5e9e 100644 --- a/pkg/types/defaults/machinepools_test.go +++ b/pkg/types/defaults/machinepools_test.go @@ -7,7 +7,8 @@ import ( configv1 "github.com/openshift/api/config/v1" "github.com/openshift/installer/pkg/types" - "github.com/openshift/installer/pkg/types/gcp" + "github.com/openshift/installer/pkg/types/aws" + gcp "github.com/openshift/installer/pkg/types/gcp" ) func defaultMachinePoolWithReplicaCount(name string, replicaCount int) *types.MachinePool { @@ -144,53 +145,48 @@ func TestSetMahcinePoolDefaults(t *testing.T) { } func TestSetMachinePoolDefaultsWithFeatureGates(t *testing.T) { + awsPlatform := &types.Platform{AWS: &aws.Platform{}} + cases := []struct { name string pool *types.MachinePool platform *types.Platform - featureSet configv1.FeatureSet + featureGates []string expectedManagement types.MachineManagementAPI }{ { - name: "control plane with DevPreviewNoUpgrade feature set", - pool: &types.MachinePool{Name: types.MachinePoolControlPlaneRoleName}, - platform: &types.Platform{}, - featureSet: configv1.DevPreviewNoUpgrade, + name: "AWS compute sets ClusterAPI management when ClusterAPIMachineManagementAWS enabled", + pool: &types.MachinePool{Name: types.MachinePoolComputeRoleName}, + platform: awsPlatform, + featureGates: []string{"ClusterAPIMachineManagementAWS=True"}, expectedManagement: types.ClusterAPI, }, { - name: "control plane with default feature set", - pool: &types.MachinePool{Name: types.MachinePoolControlPlaneRoleName}, - platform: &types.Platform{}, - featureSet: configv1.Default, + name: "AWS compute management is unchanged when ClusterAPIMachineManagementAWS disabled", + pool: &types.MachinePool{Name: types.MachinePoolComputeRoleName}, + platform: awsPlatform, + featureGates: []string{"ClusterAPIMachineManagementAWS=False"}, expectedManagement: "", }, { - name: "compute with DevPreviewNoUpgrade feature set", - pool: &types.MachinePool{Name: types.MachinePoolComputeRoleName}, - platform: &types.Platform{}, - featureSet: configv1.DevPreviewNoUpgrade, - expectedManagement: types.ClusterAPI, + name: "AWS control plane is unaffected by ClusterAPIMachineManagementAWS", + pool: &types.MachinePool{Name: types.MachinePoolControlPlaneRoleName}, + platform: awsPlatform, + featureGates: []string{"ClusterAPIMachineManagementAWS=True"}, + expectedManagement: "", }, { - name: "compute with default feature set", + name: "non-AWS compute is unaffected by ClusterAPIMachineManagementAWS", pool: &types.MachinePool{Name: types.MachinePoolComputeRoleName}, platform: &types.Platform{}, - featureSet: configv1.Default, + featureGates: []string{"ClusterAPIMachineManagementAWS=True"}, expectedManagement: "", }, { - name: "control plane with management already set", - pool: &types.MachinePool{Name: types.MachinePoolControlPlaneRoleName, Management: types.MachineAPI}, - platform: &types.Platform{}, - featureSet: configv1.DevPreviewNoUpgrade, - expectedManagement: types.MachineAPI, - }, - { - name: "compute with management already set", + name: "AWS compute management is not overwritten when already set", pool: &types.MachinePool{Name: types.MachinePoolComputeRoleName, Management: types.MachineAPI}, - platform: &types.Platform{}, - featureSet: configv1.DevPreviewNoUpgrade, + platform: awsPlatform, + featureGates: []string{"ClusterAPIMachineManagementAWS=True"}, expectedManagement: types.MachineAPI, }, } @@ -198,7 +194,8 @@ func TestSetMachinePoolDefaultsWithFeatureGates(t *testing.T) { for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { config := &types.InstallConfig{ - FeatureSet: tc.featureSet, + FeatureSet: configv1.CustomNoUpgrade, + FeatureGates: tc.featureGates, } SetMachinePoolDefaults(tc.pool, tc.platform, config.EnabledFeatureGates()) assert.Equal(t, tc.expectedManagement, tc.pool.Management, "unexpected management API") diff --git a/pkg/types/validation/featuregates.go b/pkg/types/validation/featuregates.go index c66d521d30d..33366e32c76 100644 --- a/pkg/types/validation/featuregates.go +++ b/pkg/types/validation/featuregates.go @@ -42,12 +42,9 @@ func validateMachinePoolFeatureGates(c *types.InstallConfig) []featuregates.Gate Field: field.NewPath("osImageStream"), }, { - FeatureGateName: features.FeatureGateClusterAPIControlPlaneInstall, - Condition: c.ControlPlane != nil && c.ControlPlane.Management == types.ClusterAPI, - Field: field.NewPath("controlPlane", "management"), - }, - { - FeatureGateName: features.FeatureGateClusterAPIComputeInstall, + // Note that this should use a platform-specific feature gate, but + // there is no way to express that here. + FeatureGateName: features.FeatureGateClusterAPIMachineManagement, Condition: len(c.Compute) > 0 && c.Compute[0].Management == types.ClusterAPI, Field: field.NewPath("compute", "management"), },