You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Check if host placement is configured. If so, then we need to determine placement affinity and validate configs.
902
+
ifproviderSpec.HostPlacement!=nil {
903
+
placement:=*providerSpec.HostPlacement
904
+
ifplacement.Affinity==nil {
905
+
errs=append(errs, field.Required(field.NewPath("spec.hostPlacement.affinity"), "affinity is required and must be set"))
906
+
} else {
907
+
switch*placement.Affinity {
908
+
casemachinev1beta1.HostAffinityAnyAvailable:
909
+
// Cannot have DedicatedHost set
910
+
ifplacement.DedicatedHost!=nil {
911
+
errs=append(errs, field.Forbidden(field.NewPath("spec.hostPlacement.dedicatedHost"), "dedicatedHost is not allowed when affinity is AnyAvailable"))
912
+
}
913
+
casemachinev1beta1.HostAffinityDedicatedHost:
914
+
// We need to make sure DedicatedHost is set with a HostID
915
+
ifplacement.DedicatedHost==nil {
916
+
errs=append(errs, field.Required(field.NewPath("spec.hostPlacement.dedicatedHost"), "dedicatedHost is required when affinity is DedicatedHost"))
917
+
} elseifplacement.DedicatedHost.ID=="" {
918
+
errs=append(errs, field.Invalid(field.NewPath("spec.hostPlacement.dedicatedHost.id"), placement.DedicatedHost.ID, "id must start with 'h-' followed by 17 lowercase hexadecimal characters (0-9 and a-f)"))
919
+
}
920
+
default:
921
+
errs=append(errs, field.Invalid(field.NewPath("spec.hostPlacement.affinity"), placement.Affinity, "affinity is required and must be set to an allowed value"))
expectedError: "admission webhook \"validation.machine.machine.openshift.io\" denied the request: spec.hostID: Required value: hostID must be set when hostAffinity is configured", // true
expectedError: "admission webhook \"validation.machine.machine.openshift.io\" denied the request: spec.hostID: Required value: hostID must be set when hostAffinity is configured", // true
0 commit comments