Skip to content

Commit 3bf0f84

Browse files
fix(webhook): remove default workerConfig checks
1 parent ff50056 commit 3bf0f84

File tree

2 files changed

+5
-35
lines changed

2 files changed

+5
-35
lines changed

pkg/webhook/cluster/nutanix_validator.go

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -200,33 +200,6 @@ func validateWorkerFailureDomainConfig(
200200
fmt.Errorf("failed to unmarshal cluster topology variable %q: %w", v1alpha1.WorkerConfigVariableName, err)))
201201
}
202202

203-
// Check if control plane has failure domains configured - this affects default worker config validation
204-
controlPlaneHasFailureDomains := false
205-
if clusterConfig != nil && clusterConfig.ControlPlane != nil && clusterConfig.ControlPlane.Nutanix != nil {
206-
controlPlaneHasFailureDomains = len(clusterConfig.ControlPlane.Nutanix.FailureDomains) > 0
207-
}
208-
209-
// Validate default worker config when control plane has failure domains
210-
if controlPlaneHasFailureDomains && defaultWorkerConfig != nil && defaultWorkerConfig.Nutanix != nil {
211-
machineDetails := defaultWorkerConfig.Nutanix.MachineDetails
212-
hasCluster := machineDetails.Cluster != nil &&
213-
(machineDetails.Cluster.IsName() || machineDetails.Cluster.IsUUID())
214-
hasSubnets := len(machineDetails.Subnets) > 0
215-
216-
if hasCluster {
217-
fldErrs = append(fldErrs, field.Forbidden(
218-
workerConfigVarPath.Child("value", "nutanix", "machineDetails", "cluster"),
219-
"\"cluster\" must not be set when control plane failureDomains are configured.",
220-
))
221-
}
222-
if hasSubnets {
223-
fldErrs = append(fldErrs, field.Forbidden(
224-
workerConfigVarPath.Child("value", "nutanix", "machineDetails", "subnets"),
225-
"\"subnets\" must not be set when control plane failureDomains are configured.",
226-
))
227-
}
228-
}
229-
230203
if cluster.Spec.Topology.Workers != nil {
231204
for i := range cluster.Spec.Topology.Workers.MachineDeployments {
232205
md := cluster.Spec.Topology.Workers.MachineDeployments[i]

pkg/webhook/cluster/nutanix_validator_test.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -362,14 +362,11 @@ func TestValidateTopologyFailureDomainConfig(t *testing.T) {
362362
},
363363
},
364364
{
365-
name: "default workerConfig variable with cluster/subnets set when control plane has failureDomains violates XOR", //nolint:lll // name is long.
366-
clusterConfig: fakeClusterConfigSpec(true, false, false),
367-
cluster: fakeCluster(t, false, true, true, workerConfigDefaultOnly),
368-
expectedErr: true,
369-
expectedErrMessages: []string{
370-
"spec.topology.variables.workerConfig.value.nutanix.machineDetails.cluster: Forbidden: \"cluster\" must not be set when control plane failureDomains are configured.", //nolint:lll // Message is long.
371-
"spec.topology.variables.workerConfig.value.nutanix.machineDetails.subnets: Forbidden: \"subnets\" must not be set when control plane failureDomains are configured.", //nolint:lll // Message is long.
372-
},
365+
name: "default workerConfig variable with cluster/subnets set when control plane has failureDomains should be allowed", //nolint:lll // name is long.
366+
clusterConfig: fakeClusterConfigSpec(true, false, false),
367+
cluster: fakeCluster(t, false, true, true, workerConfigDefaultOnly),
368+
expectedErr: false,
369+
expectedErrMessages: nil,
373370
},
374371
}
375372

0 commit comments

Comments
 (0)