Skip to content

Commit d9e5e66

Browse files
committed
ic: allow multi-arch clusters for AWS when feature gate enabled
This is the first step to implement multi-arch clusters for AWS: allow users to specify a different architecture for compute nodes when the `MultiArchInstallAWS` feature gate is enabled.
1 parent 318dc21 commit d9e5e66

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

pkg/types/installconfig.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,16 @@ func ClusterAPIFeatureGateEnabled(platform string, fgs featuregates.FeatureGate)
578578
}
579579
}
580580

581+
// MultiArchFeatureGateEnabled checks whether feature gate enabling multi-arch clusters is enabled.
582+
func MultiArchFeatureGateEnabled(platform string, fgs featuregates.FeatureGate) bool {
583+
switch platform {
584+
case aws.Name:
585+
return fgs.Enabled(features.FeatureGateMultiArchInstallAWS)
586+
default:
587+
return false
588+
}
589+
}
590+
581591
// PublicAPI indicates whether the API load balancer should be public
582592
// by inspecting the cluster and operator publishing strategies.
583593
func (c *InstallConfig) PublicAPI() bool {

pkg/types/validation/installconfig.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ func ValidateInstallConfig(c *types.InstallConfig, usingAgentMethod bool) field.
124124
} else {
125125
allErrs = append(allErrs, field.Required(field.NewPath("controlPlane"), "controlPlane is required"))
126126
}
127-
allErrs = append(allErrs, validateCompute(&c.Platform, c.ControlPlane, c.Compute, field.NewPath("compute"))...)
127+
multiArchEnabled := types.MultiArchFeatureGateEnabled(c.Platform.Name(), c.EnabledFeatureGates())
128+
allErrs = append(allErrs, validateCompute(&c.Platform, c.ControlPlane, c.Compute, field.NewPath("compute"), multiArchEnabled)...)
128129
if err := validate.ImagePullSecret(c.PullSecret); err != nil {
129130
allErrs = append(allErrs, field.Invalid(field.NewPath("pullSecret"), c.PullSecret, err.Error()))
130131
}
@@ -606,7 +607,7 @@ func validateComputeEdge(platform *types.Platform, pName string, fldPath *field.
606607
return allErrs
607608
}
608609

609-
func validateCompute(platform *types.Platform, control *types.MachinePool, pools []types.MachinePool, fldPath *field.Path) field.ErrorList {
610+
func validateCompute(platform *types.Platform, control *types.MachinePool, pools []types.MachinePool, fldPath *field.Path, isMultiArchEnabled bool) field.ErrorList {
610611
allErrs := field.ErrorList{}
611612
poolNames := map[string]bool{}
612613
for i, p := range pools {
@@ -623,7 +624,7 @@ func validateCompute(platform *types.Platform, control *types.MachinePool, pools
623624
allErrs = append(allErrs, field.Duplicate(poolFldPath.Child("name"), p.Name))
624625
}
625626
poolNames[p.Name] = true
626-
if control != nil && control.Architecture != p.Architecture {
627+
if control != nil && control.Architecture != p.Architecture && !isMultiArchEnabled {
627628
allErrs = append(allErrs, field.Invalid(poolFldPath.Child("architecture"), p.Architecture, "heteregeneous multi-arch is not supported; compute pool architecture must match control plane"))
628629
}
629630
allErrs = append(allErrs, ValidateMachinePool(platform, &p, poolFldPath)...)

pkg/types/validation/installconfig_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,16 @@ func TestValidateInstallConfig(t *testing.T) {
14131413
}(),
14141414
expectedError: `^compute\[0\].architecture: Invalid value: "arm64": heteregeneous multi-arch is not supported; compute pool architecture must match control plane$`,
14151415
},
1416+
{
1417+
name: "aws cluster is heteregeneous",
1418+
installConfig: func() *types.InstallConfig {
1419+
c := validInstallConfig()
1420+
c.Compute[0].Architecture = types.ArchitectureARM64
1421+
c.FeatureSet = "CustomNoUpgrade"
1422+
c.FeatureGates = []string{"MultiArchInstallAWS=true"}
1423+
return c
1424+
}(),
1425+
},
14161426
{
14171427
name: "valid cloud credentials mode",
14181428
installConfig: func() *types.InstallConfig {

0 commit comments

Comments
 (0)