-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Use CAPI featuregate for CAPI aws worker machinesets #10659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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,61 +145,57 @@ 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{}, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: let's put a non-nil platform (e.g. GCP) to test "non-AWS" case? |
||
| 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, | ||
| }, | ||
| } | ||
|
|
||
| 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") | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -42,12 +42,9 @@ func validateMachinePoolFeatureGates(c *types.InstallConfig) []featuregates.Gate | |||||||||||
| Field: field.NewPath("osImageStream"), | ||||||||||||
| }, | ||||||||||||
| { | ||||||||||||
| FeatureGateName: features.FeatureGateClusterAPIControlPlaneInstall, | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should also remove the 2 unit tests, following this change:
|
||||||||||||
| Condition: c.ControlPlane != nil && c.ControlPlane.Management == types.ClusterAPI, | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By removing this check, field We should add a validation to block it for the moment, WDYT? installer/pkg/types/validation/installconfig.go Lines 900 to 904 in 6831905
|
||||||||||||
| 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, | ||||||||||||
|
Comment on lines
+45
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift Use the AWS-specific gate in validation, not the generic machine-management gate.
🤖 Prompt for AI Agents
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead, move it here: https://github.com/openshift/installer/blob/main/pkg/types/aws/validation/featuregates.go
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was trying to work out how to express this on Friday and didn't quite get there. I wanted to express:
The best I had was a top level
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about this idea: tthvo@28105d1 🤔? The commit added a
This would achieve your 2 requirements above, WDYT? |
||||||||||||
| Condition: len(c.Compute) > 0 && c.Compute[0].Management == types.ClusterAPI, | ||||||||||||
| Field: field.NewPath("compute", "management"), | ||||||||||||
|
Comment on lines
48
to
49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Point the validation error at the indexed compute pool.
🤖 Prompt for AI AgentsSource: Path instructions |
||||||||||||
| }, | ||||||||||||
|
|
||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we just stick with featureset?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so: it's the wrong abstraction. We'd have to change all the tests every time we promoted anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok this looks fine to me although you might need CNU featureset enabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we lose coverage for scenarios where the users set:
featureSet: Default/TechPreviewNoUpgrade/DevPreviewNoUpgradein the install-config, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not if we're testing the resulting feature gates.
I haven't checked how installer loads feature gates from a feature set, but in the running cluster you have to read them from the FeatureGate object because they can change at runtime. You cannot trust the openshift/api vendored in your binary. I believe the CVO image writes them, which (IIRC) would make the CVO image the canonical source of the contents of a feature set. Does installer read them from the same place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eh... 😅 I believe the installer reads the current state of feature gates from the vendored openshift/api. Every time any gate-related change, we re-vendor o/api.