Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/webhooks/machine_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,14 @@ func processAWSPlacementTenancy(m *machinev1beta1.Machine, placement machinev1be
case machinev1beta1.HostAffinityAnyAvailable:
// DedicatedHost is optional. If it is set, make sure it follows conventions
if placement.Host.DedicatedHost != nil {
// Dynamic Host Allocation (DHA) requires DedicatedHost affinity
strategy := machinev1beta1.AllocationStrategyUserProvided
if placement.Host.DedicatedHost.AllocationStrategy != nil {
strategy = *placement.Host.DedicatedHost.AllocationStrategy
}
if strategy == machinev1beta1.AllocationStrategyDynamic {
errs = append(errs, field.Forbidden(field.NewPath("spec.placement.host.affinity"), "hostAffinity must be DedicatedHost when using dynamic host allocation"))
}
errs = append(errs, validateDedicatedHost(placement.Host.DedicatedHost)...)
}
case machinev1beta1.HostAffinityDedicatedHost:
Expand Down
4 changes: 2 additions & 2 deletions pkg/webhooks/machine_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ func TestMachineCreation(t *testing.T) {
},
},
},
expectedError: "",
expectedError: "admission webhook \"validation.machine.machine.openshift.io\" denied the request: spec.placement.host.affinity: Forbidden: hostAffinity must be DedicatedHost when using dynamic host allocation",
},
{
name: "configure Affinity AnyAvailable with AllocationStrategy Dynamic and DynamicHostAllocation",
Expand All @@ -1032,7 +1032,7 @@ func TestMachineCreation(t *testing.T) {
},
},
},
expectedError: "",
expectedError: "admission webhook \"validation.machine.machine.openshift.io\" denied the request: spec.placement.host.affinity: Forbidden: hostAffinity must be DedicatedHost when using dynamic host allocation",
},
{
name: "control plane machine with dedicated host should fail",
Expand Down