Skip to content

Commit d0738a8

Browse files
Merge pull request #9629 from eggfoobar/fix-tna-install
OCPEDGE-1701: fix: update tnf validation to account for tna install config
2 parents 060487a + 882a000 commit d0738a8

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

pkg/types/validation/installconfig.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,9 +1560,10 @@ func isV4NodeSubnetLargeEnough(cn []types.ClusterNetworkEntry, nodeSubnet *ipnet
15601560
}
15611561

15621562
// validateCredentialsNumber in case fencing credentials exists validates there are exactly 2.
1563-
func validateCredentialsNumber(controlPlane *types.MachinePool, fencing *types.Fencing, fldPath *field.Path) field.ErrorList {
1563+
func validateCredentialsNumber(installConfig *types.InstallConfig, fencing *types.Fencing, fldPath *field.Path) field.ErrorList {
15641564
errs := field.ErrorList{}
1565-
if controlPlane == nil || controlPlane.Replicas == nil {
1565+
controlPlane := installConfig.ControlPlane
1566+
if controlPlane == nil || controlPlane.Replicas == nil || installConfig.IsArbiterEnabled() {
15661567
// invalid use case covered by a different validation.
15671568
return errs
15681569
}
@@ -1590,7 +1591,7 @@ func validateFencingCredentials(installConfig *types.InstallConfig) (errors fiel
15901591
if fencingCredentials != nil {
15911592
allErrs = append(allErrs, common.ValidateUniqueAndRequiredFields(fencingCredentials.Credentials, fldPath, func([]byte) bool { return false }, "credentials")...)
15921593
}
1593-
allErrs = append(allErrs, validateCredentialsNumber(installConfig.ControlPlane, fencingCredentials, fldPath.Child("credentials"))...)
1594+
allErrs = append(allErrs, validateCredentialsNumber(installConfig, fencingCredentials, fldPath.Child("credentials"))...)
15941595

15951596
return allErrs
15961597
}

pkg/types/validation/installconfig_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2829,6 +2829,24 @@ func TestValidateTNF(t *testing.T) {
28292829
name: "invalid_number_of_credentials_for_dual_replica",
28302830
expected: "controlPlane.fencing.credentials: Forbidden: there should be exactly two fencing credentials to support the two node cluster, instead 3 credentials were found",
28312831
},
2832+
{
2833+
config: installConfig().
2834+
MachinePoolArbiter(machinePool()).
2835+
MachinePoolCP(machinePool().Credential(c1(), c2())).
2836+
ArbiterReplicas(1).
2837+
CpReplicas(2).build(),
2838+
name: "skip_number_of_credentials_validation_for_arbiter_deployment",
2839+
expected: "",
2840+
},
2841+
{
2842+
config: installConfig().
2843+
MachinePoolArbiter(machinePool()).
2844+
MachinePoolCP(machinePool().Credential(c1(), c2(), c3())).
2845+
ArbiterReplicas(1).
2846+
CpReplicas(2).build(),
2847+
name: "skip_number_of_credentials_validation_for_arbiter_deployment_invalid_credentials_count",
2848+
expected: "",
2849+
},
28322850
{
28332851
config: installConfig().
28342852
MachinePoolCP(machinePool().
@@ -3040,6 +3058,19 @@ func (icb *installConfigBuilder) MachinePoolCP(builder *machinePoolBuilder) *ins
30403058
return icb
30413059
}
30423060

3061+
func (icb *installConfigBuilder) ArbiterReplicas(numOfCpReplicas int64) *installConfigBuilder {
3062+
if icb.InstallConfig.Arbiter == nil {
3063+
icb.InstallConfig.Arbiter = &types.MachinePool{}
3064+
}
3065+
icb.InstallConfig.Arbiter.Replicas = &numOfCpReplicas
3066+
return icb
3067+
}
3068+
3069+
func (icb *installConfigBuilder) MachinePoolArbiter(builder *machinePoolBuilder) *installConfigBuilder {
3070+
icb.InstallConfig.Arbiter = builder.build()
3071+
return icb
3072+
}
3073+
30433074
func (icb *installConfigBuilder) MachinePoolCompute(builders ...*machinePoolBuilder) *installConfigBuilder {
30443075
for _, builder := range builders {
30453076
icb.InstallConfig.Compute = append(icb.InstallConfig.Compute, *builder.build())

0 commit comments

Comments
 (0)