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.
907
+
ifproviderSpec.HostPlacement!=nil {
908
+
klog.V(4).Infof("Validating AWS Host Placement")
909
+
placement:=*providerSpec.HostPlacement
910
+
ifplacement.Affinity==nil {
911
+
errs=append(errs, field.Required(field.NewPath("spec.hostPlacement.affinity"), "affinity is required and must be set to either AnyAvailable or DedicatedHost"))
912
+
} else {
913
+
switch*placement.Affinity {
914
+
casemachinev1beta1.HostAffinityAnyAvailable:
915
+
// Cannot have DedicatedHost set
916
+
ifplacement.DedicatedHost!=nil {
917
+
errs=append(errs, field.Forbidden(field.NewPath("spec.hostPlacement.dedicatedHost"), "dedicatedHost is required when affinity is DedicatedHost, and forbidden otherwise"))
918
+
}
919
+
casemachinev1beta1.HostAffinityDedicatedHost:
920
+
// We need to make sure DedicatedHost is set with a HostID
921
+
ifplacement.DedicatedHost==nil {
922
+
errs=append(errs, field.Required(field.NewPath("spec.hostPlacement.dedicatedHost"), "dedicatedHost is required when affinity is DedicatedHost, and forbidden otherwise"))
923
+
} else {
924
+
// If not set, return required error. If it does not match pattern, return pattern failure message.
925
+
ifplacement.DedicatedHost.ID=="" {
926
+
errs=append(errs, field.Required(field.NewPath("spec.hostPlacement.dedicatedHost.id"), "id is required and must start with 'h-' followed by 17 lowercase hexadecimal characters (0-9 and a-f)"))
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)"))
929
+
}
930
+
}
931
+
default:
932
+
errs=append(errs, field.Invalid(field.NewPath("spec.hostPlacement.affinity"), placement.Affinity, "affinity must be either AnyAvailable or DedicatedHost"))
expectedError: "admission webhook \"validation.machine.machine.openshift.io\" denied the request: spec.hostPlacement.affinity: Invalid value: \"invalid\": affinity must be either AnyAvailable or DedicatedHost",
352
+
},
353
+
{
354
+
name: "configure host placement dedicatedHost without dedicatedHost",
expectedError: "admission webhook \"validation.machine.machine.openshift.io\" denied the request: spec.hostPlacement.dedicatedHost: Required value: dedicatedHost is required when affinity is DedicatedHost",
369
+
},
370
+
{
371
+
name: "configure host placement dedicatedHost with valid ID",
expectedError: "admission webhook \"validation.machine.machine.openshift.io\" denied the request: spec.hostPlacement.dedicatedHost: Forbidden: dedicatedHost is required when affinity is DedicatedHost, and forbidden otherwise",
403
+
},
404
+
{
405
+
name: "configure host placement dedicatedHost with empty ID",
expectedError: "admission webhook \"validation.machine.machine.openshift.io\" denied the request: spec.hostPlacement.dedicatedHost.id: Invalid value: \"\": id must start with 'h-' followed by 17 lowercase hexadecimal characters (0-9 and a-f)",
419
+
},
420
+
{
421
+
name: "configure host placement dedicatedHost with ID not set",
expectedError: "admission webhook \"validation.machine.machine.openshift.io\" denied the request: spec.hostPlacement.dedicatedHost.id: Invalid value: \"\": id must start with 'h-' followed by 17 lowercase hexadecimal characters (0-9 and a-f)",
expectedError: `providerSpec.tagIDs: Invalid value: []string{"urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9500:GLOBAL","urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9501:GLOBAL","urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9502:GLOBAL","urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9503:GLOBAL","urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9504:GLOBAL","urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9505:GLOBAL","urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9506:GLOBAL","urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9507:GLOBAL","urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9508:GLOBAL","urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9509:GLOBAL","urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9510:GLOBAL","urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9511:GLOBAL"}: a maximum of 10 tags are allowed`,
2078
+
expectedError: `providerSpec.tagIDs: Invalid value: ["urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9500:GLOBAL","urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9501:GLOBAL","urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9502:GLOBAL","urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9503:GLOBAL","urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9504:GLOBAL","urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9505:GLOBAL","urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9506:GLOBAL","urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9507:GLOBAL","urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9508:GLOBAL","urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9509:GLOBAL","urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9510:GLOBAL","urn:vmomi:InventoryServiceTag:5736bf56-49f5-4667-b38c-b97e09dc9511:GLOBAL"]: a maximum of 10 tags are allowed`,
1962
2079
},
1963
2080
{
1964
2081
name: "with an VSphere ProviderSpec, removing the template",
expectedError: "providerSpec.diagnostics.boot.customerManaged: Invalid value: v1beta1.AzureCustomerManagedBootDiagnostics{StorageAccountURI:\"https://storageaccount.blob.core.windows.net/\"}: customerManaged may not be set when type is AzureManaged",
3420
+
expectedError: "providerSpec.diagnostics.boot.customerManaged: Invalid value: {\"storageAccountURI\":\"https://storageaccount.blob.core.windows.net/\"}: customerManaged may not be set when type is AzureManaged",
3304
3421
},
3305
3422
{
3306
3423
testCase: "with Customer Managed boot diagnostics, with a missing storage account URI",
expectedError: "[spec.selector: Forbidden: selector is immutable, spec.template.metadata.labels: Invalid value: map[string]string{\"machineset-name\":\"machineset-update-abcd\"}: `selector` does not match template `labels`]",
1050
+
expectedError: "[spec.selector: Forbidden: selector is immutable, spec.template.metadata.labels: Invalid value: {\"machineset-name\":\"machineset-update-abcd\"}: `selector` does not match template `labels`]",
0 commit comments