dra API: ensure that pod status contains no duplicate resource claims
This is a follow-up to https://github.com/kubernetes/kubernetes/pull/117351 which just got merged.
This commit is contained in:
@@ -4871,6 +4871,7 @@ func validatePodConditions(conditions []core.PodCondition, fldPath *field.Path)
|
||||
func validatePodResourceClaimStatuses(statuses []core.PodResourceClaimStatus, podClaims []core.PodResourceClaim, fldPath *field.Path) field.ErrorList {
|
||||
var allErrs field.ErrorList
|
||||
|
||||
claimNames := sets.New[string]()
|
||||
for i, status := range statuses {
|
||||
idxPath := fldPath.Index(i)
|
||||
// There's no need to check the content of the name. If it matches an entry,
|
||||
@@ -4878,6 +4879,11 @@ func validatePodResourceClaimStatuses(statuses []core.PodResourceClaimStatus, po
|
||||
if !havePodClaim(podClaims, status.Name) {
|
||||
allErrs = append(allErrs, field.Invalid(idxPath.Child("name"), status.Name, "must match the name of an entry in `spec.resourceClaims`"))
|
||||
}
|
||||
if claimNames.Has(status.Name) {
|
||||
allErrs = append(allErrs, field.Duplicate(idxPath.Child("name"), status.Name))
|
||||
} else {
|
||||
claimNames.Insert(status.Name)
|
||||
}
|
||||
if status.ResourceClaimName != nil {
|
||||
for _, detail := range ValidateResourceClaimName(*status.ResourceClaimName, false) {
|
||||
allErrs = append(allErrs, field.Invalid(idxPath.Child("name"), status.ResourceClaimName, detail))
|
||||
|
Reference in New Issue
Block a user