@@ -48,6 +48,7 @@ import (
4848 "github.com/openshift/installer/pkg/types/vsphere"
4949 vspherevalidation "github.com/openshift/installer/pkg/types/vsphere/validation"
5050 "github.com/openshift/installer/pkg/validate"
51+ "github.com/openshift/installer/pkg/version"
5152)
5253
5354// hostCryptBypassedAnnotation is set if the host crypt check was bypassed via environment variable.
@@ -126,6 +127,9 @@ func ValidateInstallConfig(c *types.InstallConfig, usingAgentMethod bool) field.
126127 }
127128 multiArchEnabled := types .MultiArchFeatureGateEnabled (c .Platform .Name (), c .EnabledFeatureGates ())
128129 allErrs = append (allErrs , validateCompute (& c .Platform , c .ControlPlane , c .Compute , field .NewPath ("compute" ), multiArchEnabled )... )
130+ if multiArchEnabled {
131+ allErrs = append (allErrs , validateMultiReleasePayload (c .ControlPlane , c .Compute )... )
132+ }
129133 if err := validate .ImagePullSecret (c .PullSecret ); err != nil {
130134 allErrs = append (allErrs , field .Invalid (field .NewPath ("pullSecret" ), c .PullSecret , err .Error ()))
131135 }
@@ -1298,3 +1302,40 @@ func validateGatedFeatures(c *types.InstallConfig) field.ErrorList {
12981302
12991303 return allErrs
13001304}
1305+
1306+ // validateMultiReleasePayload ensures a multi payload is used when a multi-arch cluster config is enabled.
1307+ func validateMultiReleasePayload (controlPlanePool * types.MachinePool , computePool []types.MachinePool ) field.ErrorList {
1308+ allErrs := field.ErrorList {}
1309+
1310+ releaseArch , err := version .ReleaseArchitecture ()
1311+ if err != nil {
1312+ return append (allErrs , field .InternalError (field .NewPath ("" ), err ))
1313+ }
1314+
1315+ switch releaseArch {
1316+ case "multi" :
1317+ // All good
1318+ case "unknown" :
1319+ for _ , p := range computePool {
1320+ if controlPlanePool != nil && controlPlanePool .Architecture != p .Architecture {
1321+ // Overriding release architecture is a must during dev/CI so just log a warning instead of erroring out
1322+ logrus .Warnln ("Could not determine release architecture for multi arch cluster configuration. Make sure the release is a multi architecture payload." )
1323+ break
1324+ }
1325+ }
1326+ default :
1327+ if controlPlanePool != nil && controlPlanePool .Architecture != types .Architecture (releaseArch ) {
1328+ errMsg := fmt .Sprintf ("cannot create %s controlPlane node from a single architecture %s release payload" , controlPlanePool .Architecture , releaseArch )
1329+ allErrs = append (allErrs , field .Invalid (field .NewPath ("controlPlane" , "architecture" ), controlPlanePool .Architecture , errMsg ))
1330+ }
1331+ for i , p := range computePool {
1332+ poolFldPath := field .NewPath ("compute" ).Index (i )
1333+ if p .Architecture != types .Architecture (releaseArch ) {
1334+ errMsg := fmt .Sprintf ("cannot create %s compute node from a single architecture %s release payload" , p .Architecture , releaseArch )
1335+ allErrs = append (allErrs , field .Invalid (poolFldPath .Child ("architecture" ), p .Architecture , errMsg ))
1336+ }
1337+ }
1338+ }
1339+
1340+ return allErrs
1341+ }
0 commit comments