in pkg/webhooks/workload_webhook.go [161:190]
func validateAdmission(obj *kueue.Workload, path *field.Path) field.ErrorList {
admission := obj.Status.Admission
var allErrs field.ErrorList
allErrs = append(allErrs, validateNameReference(string(admission.ClusterQueue), path.Child("clusterQueue"))...)
names := sets.NewString()
for _, ps := range obj.Spec.PodSets {
names.Insert(ps.Name)
}
assigmentsPath := path.Child("podSetAssignments")
if names.Len() != len(admission.PodSetAssignments) {
allErrs = append(allErrs, field.Invalid(assigmentsPath, field.OmitValueType{}, "must have the same number of podSets as the spec"))
}
for i, ps := range admission.PodSetAssignments {
psaPath := assigmentsPath.Index(i)
if !names.Has(ps.Name) {
allErrs = append(allErrs, field.NotFound(psaPath.Child("name"), ps.Name))
}
if ps.Count > 0 {
for k, v := range ps.ResourceUsage {
if (workload.ResourceValue(k, v) % int64(ps.Count)) != 0 {
allErrs = append(allErrs, field.Invalid(psaPath.Child("resourceUsage").Key(string(k)), v, fmt.Sprintf("is not a multiple of %d", ps.Count)))
}
}
}
}
return allErrs
}