diff --git a/pkg/types/validation/installconfig.go b/pkg/types/validation/installconfig.go index bda2e4562d..30f3c12053 100644 --- a/pkg/types/validation/installconfig.go +++ b/pkg/types/validation/installconfig.go @@ -39,6 +39,7 @@ import ( gcpvalidation "github.com/openshift/installer/pkg/types/gcp/validation" "github.com/openshift/installer/pkg/types/ibmcloud" ibmcloudvalidation "github.com/openshift/installer/pkg/types/ibmcloud/validation" + "github.com/openshift/installer/pkg/types/none" "github.com/openshift/installer/pkg/types/nutanix" nutanixvalidation "github.com/openshift/installer/pkg/types/nutanix/validation" "github.com/openshift/installer/pkg/types/openstack" @@ -770,8 +771,8 @@ func validateControlPlane(installConfig *types.InstallConfig, fldPath *field.Pat func validateArbiter(platform *types.Platform, arbiterPool, masterPool *types.MachinePool, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} - if platform != nil && platform.BareMetal == nil { - allErrs = append(allErrs, field.NotSupported(fldPath.Child("platform"), platform.Name(), []string{baremetal.Name})) + if platform != nil && (platform.BareMetal == nil && platform.None == nil && platform.External == nil) { + allErrs = append(allErrs, field.NotSupported(fldPath.Child("platform"), platform.Name(), []string{baremetal.Name, none.Name, external.Name})) } if arbiterPool.Name != types.MachinePoolArbiterRoleName { allErrs = append(allErrs, field.NotSupported(fldPath.Child("name"), arbiterPool.Name, []string{types.MachinePoolArbiterRoleName})) diff --git a/pkg/types/validation/installconfig_test.go b/pkg/types/validation/installconfig_test.go index 1546c8c1d3..97bb6a7cfc 100644 --- a/pkg/types/validation/installconfig_test.go +++ b/pkg/types/validation/installconfig_test.go @@ -2888,6 +2888,120 @@ func TestValidateReleaseArchitecture(t *testing.T) { }) } +func TestValidateArbiter(t *testing.T) { + cases := []struct { + name string + config *types.InstallConfig + machinePool *types.MachinePool + expected string + }{ + { + config: installConfig(). + PlatformNone(). + MachinePoolArbiter( + machinePool(). + Name("arbiter"). + Hyperthreading(types.HyperthreadingEnabled). + Architecture(types.ArchitectureAMD64)). + MachinePoolCP(machinePool()). + ArbiterReplicas(1). + CpReplicas(2).build(), + name: "valid_platform_none", + expected: "", + }, + { + config: installConfig(). + PlatformExternal(). + MachinePoolArbiter( + machinePool(). + Name("arbiter"). + Hyperthreading(types.HyperthreadingEnabled). + Architecture(types.ArchitectureAMD64)). + MachinePoolCP(machinePool()). + ArbiterReplicas(1). + CpReplicas(2).build(), + name: "valid_platform_external", + expected: "", + }, + { + config: installConfig(). + PlatformNone(). + MachinePoolArbiter( + machinePool(). + Name("arbiter"). + Hyperthreading(types.HyperthreadingEnabled). + Architecture(types.ArchitectureAMD64)). + MachinePoolCP(machinePool()). + ArbiterReplicas(1). + CpReplicas(2).build(), + name: "valid_platform_baremetal", + expected: "", + }, + { + config: installConfig(). + PlatformAWS(). + MachinePoolArbiter(machinePool(). + Name("arbiter"). + Hyperthreading(types.HyperthreadingEnabled). + Architecture(types.ArchitectureAMD64)). + MachinePoolCP(machinePool()). + ArbiterReplicas(1). + CpReplicas(2).build(), + name: "invalid_platform", + expected: `supported values: "baremetal", "none", "external"`, + }, + { + config: installConfig(). + PlatformNone(). + MachinePoolArbiter(machinePool(). + Hyperthreading(types.HyperthreadingEnabled). + Architecture(types.ArchitectureAMD64)). + MachinePoolCP(machinePool()). + ArbiterReplicas(1). + CpReplicas(2).build(), + name: "invalid_arbiter_machine_pool_name", + expected: `arbiter.name: Unsupported value:`, + }, + { + config: installConfig(). + PlatformNone(). + MachinePoolArbiter(machinePool(). + Name("arbiter"). + Hyperthreading(types.HyperthreadingEnabled). + Architecture(types.ArchitectureAMD64)). + MachinePoolCP(machinePool()). + ArbiterReplicas(0). + CpReplicas(2).build(), + name: "invalid_arbiter_machine_pool_size", + expected: `arbiter.replicas: Invalid value:`, + }, + { + config: installConfig(). + PlatformNone(). + MachinePoolArbiter(machinePool(). + Name("arbiter"). + Hyperthreading(types.HyperthreadingEnabled). + Architecture(types.ArchitectureAMD64)). + MachinePoolCP(machinePool()). + ArbiterReplicas(1). + CpReplicas(1).build(), + name: "invalid_master_machine_pool_size", + expected: `number of controlPlane replicas must be at least 2`, + }, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + err := validateArbiter(&tc.config.Platform, tc.config.Arbiter, tc.config.ControlPlane, field.NewPath("arbiter")).ToAggregate() + + if tc.expected == "" { + assert.NoError(t, err) + } else { + assert.Regexp(t, tc.expected, err) + } + }) + } +} + func TestValidateTNF(t *testing.T) { cases := []struct { name string