Skip to content

Commit d7d2bfc

Browse files
committed
Use CAPI featuregate for CAPI aws worker machinesets
This removes use of: * FeatureGateClusterAPIControlPlaneInstall because it is not implemented in either installer or CPMS. * FeatureGateClusterAPIComputeInstall replaced by FeatureGateClusterAPIMachineManagementAWS and scoped to AWS only, as that is the only platform where it is implemented The effect of this change is that installer-created worker machinesets will use CAPI as soon as platform support is promoted. Also updates the tests to use the feature gates explicitly instead of assuming inclusion in a particular feature set.
1 parent ab2b202 commit d7d2bfc

2 files changed

Lines changed: 28 additions & 38 deletions

File tree

pkg/types/defaults/machinepools.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,11 @@ func SetMachinePoolDefaults(p *types.MachinePool, platform *types.Platform, fgat
4040
}
4141
}
4242

43-
// Set management to ClusterAPI if the appropriate feature gate is enabled and management is unspecified
44-
if p.Management == "" {
45-
if p.Name == types.MachinePoolControlPlaneRoleName && fgates.Enabled(features.FeatureGateClusterAPIControlPlaneInstall) {
46-
p.Management = types.ClusterAPI
47-
}
48-
if p.Name == types.MachinePoolComputeRoleName && fgates.Enabled(features.FeatureGateClusterAPIComputeInstall) {
49-
p.Management = types.ClusterAPI
50-
}
51-
}
52-
5343
switch platform.Name() {
5444
case aws.Name:
45+
if p.Management == "" && p.Name == types.MachinePoolComputeRoleName && fgates.Enabled(features.FeatureGateClusterAPIMachineManagementAWS) {
46+
p.Management = types.ClusterAPI
47+
}
5548
if p.Platform.AWS == nil && platform.AWS.DefaultMachinePlatform != nil {
5649
p.Platform.AWS = &aws.MachinePool{}
5750
}

pkg/types/defaults/machinepools_test.go

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import (
77

88
configv1 "github.com/openshift/api/config/v1"
99
"github.com/openshift/installer/pkg/types"
10-
"github.com/openshift/installer/pkg/types/gcp"
10+
"github.com/openshift/installer/pkg/types/aws"
11+
gcp "github.com/openshift/installer/pkg/types/gcp"
1112
)
1213

1314
func defaultMachinePoolWithReplicaCount(name string, replicaCount int) *types.MachinePool {
@@ -144,61 +145,57 @@ func TestSetMahcinePoolDefaults(t *testing.T) {
144145
}
145146

146147
func TestSetMachinePoolDefaultsWithFeatureGates(t *testing.T) {
148+
awsPlatform := &types.Platform{AWS: &aws.Platform{}}
149+
147150
cases := []struct {
148151
name string
149152
pool *types.MachinePool
150153
platform *types.Platform
151-
featureSet configv1.FeatureSet
154+
featureGates []string
152155
expectedManagement types.MachineManagementAPI
153156
}{
154157
{
155-
name: "control plane with DevPreviewNoUpgrade feature set",
156-
pool: &types.MachinePool{Name: types.MachinePoolControlPlaneRoleName},
157-
platform: &types.Platform{},
158-
featureSet: configv1.DevPreviewNoUpgrade,
158+
name: "AWS compute sets ClusterAPI management when ClusterAPIMachineManagementAWS enabled",
159+
pool: &types.MachinePool{Name: types.MachinePoolComputeRoleName},
160+
platform: awsPlatform,
161+
featureGates: []string{"ClusterAPIMachineManagementAWS=True"},
159162
expectedManagement: types.ClusterAPI,
160163
},
161164
{
162-
name: "control plane with default feature set",
163-
pool: &types.MachinePool{Name: types.MachinePoolControlPlaneRoleName},
164-
platform: &types.Platform{},
165-
featureSet: configv1.Default,
165+
name: "AWS compute management is unchanged when ClusterAPIMachineManagementAWS disabled",
166+
pool: &types.MachinePool{Name: types.MachinePoolComputeRoleName},
167+
platform: awsPlatform,
168+
featureGates: []string{"ClusterAPIMachineManagementAWS=False"},
166169
expectedManagement: "",
167170
},
168171
{
169-
name: "compute with DevPreviewNoUpgrade feature set",
170-
pool: &types.MachinePool{Name: types.MachinePoolComputeRoleName},
171-
platform: &types.Platform{},
172-
featureSet: configv1.DevPreviewNoUpgrade,
173-
expectedManagement: types.ClusterAPI,
172+
name: "AWS control plane is unaffected by ClusterAPIMachineManagementAWS",
173+
pool: &types.MachinePool{Name: types.MachinePoolControlPlaneRoleName},
174+
platform: awsPlatform,
175+
featureGates: []string{"ClusterAPIMachineManagementAWS=True"},
176+
expectedManagement: "",
174177
},
175178
{
176-
name: "compute with default feature set",
179+
name: "non-AWS compute is unaffected by ClusterAPIMachineManagementAWS",
177180
pool: &types.MachinePool{Name: types.MachinePoolComputeRoleName},
178181
platform: &types.Platform{},
179-
featureSet: configv1.Default,
182+
featureGates: []string{"ClusterAPIMachineManagementAWS=True"},
180183
expectedManagement: "",
181184
},
182185
{
183-
name: "control plane with management already set",
184-
pool: &types.MachinePool{Name: types.MachinePoolControlPlaneRoleName, Management: types.MachineAPI},
185-
platform: &types.Platform{},
186-
featureSet: configv1.DevPreviewNoUpgrade,
187-
expectedManagement: types.MachineAPI,
188-
},
189-
{
190-
name: "compute with management already set",
186+
name: "AWS compute management is not overwritten when already set",
191187
pool: &types.MachinePool{Name: types.MachinePoolComputeRoleName, Management: types.MachineAPI},
192-
platform: &types.Platform{},
193-
featureSet: configv1.DevPreviewNoUpgrade,
188+
platform: awsPlatform,
189+
featureGates: []string{"ClusterAPIMachineManagementAWS=True"},
194190
expectedManagement: types.MachineAPI,
195191
},
196192
}
197193

198194
for _, tc := range cases {
199195
t.Run(tc.name, func(t *testing.T) {
200196
config := &types.InstallConfig{
201-
FeatureSet: tc.featureSet,
197+
FeatureSet: configv1.CustomNoUpgrade,
198+
FeatureGates: tc.featureGates,
202199
}
203200
SetMachinePoolDefaults(tc.pool, tc.platform, config.EnabledFeatureGates())
204201
assert.Equal(t, tc.expectedManagement, tc.pool.Management, "unexpected management API")

0 commit comments

Comments
 (0)