Merge pull request #127397 from kannon92/cleanup-dra-deterministic-name

remove 1.27 deterministic support for resource claims
This commit is contained in:
Kubernetes Prow Robot 2024-09-18 14:30:43 +01:00 committed by GitHub
commit e367afe3bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 21 deletions

View File

@ -678,23 +678,20 @@ func (ec *Controller) findPodResourceClaim(pod *v1.Pod, podClaim v1.PodResourceC
if err != nil {
return nil, err
}
deterministicName := pod.Name + "-" + podClaim.Name // Kubernetes <= 1.27 behavior.
for _, claimObj := range claims {
claim, ok := claimObj.(*resourceapi.ResourceClaim)
if !ok {
return nil, fmt.Errorf("unexpected object of type %T returned by claim cache", claimObj)
}
podClaimName, ok := claim.Annotations[podResourceClaimAnnotation]
if ok && podClaimName != podClaim.Name {
// No annotation? Then it cannot be an automatically generated claim
// and we need to ignore it.
if !ok {
continue
}
// No annotation? It might a ResourceClaim created for
// the pod with a previous Kubernetes release where the
// ResourceClaim name was deterministic, in which case
// we have to use it and update the new pod status
// field accordingly.
if !ok && claim.Name != deterministicName {
// Not the claim for this particular pod claim?
if podClaimName != podClaim.Name {
continue
}

View File

@ -190,19 +190,6 @@ func TestSyncHandler(t *testing.T) {
},
expectedMetrics: expectedMetrics{0, 0},
},
{
name: "find-existing-claim-by-name",
pods: []*v1.Pod{testPodWithResource},
key: podKey(testPodWithResource),
claims: []*resourceapi.ResourceClaim{testClaim},
expectedClaims: []resourceapi.ResourceClaim{*testClaim},
expectedStatuses: map[string][]v1.PodResourceClaimStatus{
testPodWithResource.Name: {
{Name: testPodWithResource.Spec.ResourceClaims[0].Name, ResourceClaimName: &testClaim.Name},
},
},
expectedMetrics: expectedMetrics{0, 0},
},
{
name: "find-created-claim-in-cache",
pods: []*v1.Pod{testPodWithResource},