Validating webhook for IOThreadsPolicy
@@ -53,6 +53,7 @@ const (
)
var validInterfaceModels = []string{"e1000", "e1000e", "ne2k_pci", "pcnet", "rtl8139", "virtio"}
+var validIOThreadsPolicies = []string{"shared", "dedicated"}
func toAdmissionResponse(causes []metav1.StatusCause) *v1beta1.AdmissionResponse {
log.Log.Infof("rejected vmi admission")
@@ -918,6 +919,24 @@ func ValidateVirtualMachineInstanceSpec(field *k8sfield.Path, spec *v1.VirtualMa
}
}
+ if spec.Domain.IOThreadsPolicy != nil {
+ isValidPolicy := func(policy string) bool {
+ for _, p := range validIOThreadsPolicies {
+ if policy == p {
+ return true
+ }
+ }
+ return false
+ }
+ if !isValidPolicy(*spec.Domain.IOThreadsPolicy) {
+ causes = append(causes, metav1.StatusCause{
+ Type: metav1.CauseTypeFieldValueInvalid,
+ Message: fmt.Sprintf("Invalid IOThreadsPolicy (%s)", *spec.Domain.IOThreadsPolicy),
+ Field: field.Child("domain", "ioThreadsPolicy").String(),
+ })
+ }
+ }
+
causes = append(causes, validateDomainSpec(field.Child("domain"), &spec.Domain)...)
causes = append(causes, validateVolumes(field.Child("volumes"), spec.Volumes)...)
return causes
