From 03da672159ed1c3ee5f5128be30ae3eda4b13949 Mon Sep 17 00:00:00 2001 From: Kevin Hannon Date: Mon, 16 Sep 2024 11:06:59 -0400 Subject: [PATCH] remove 1.27 deterministic support for resource claims --- pkg/controller/resourceclaim/controller.go | 13 +++++-------- pkg/controller/resourceclaim/controller_test.go | 13 ------------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/pkg/controller/resourceclaim/controller.go b/pkg/controller/resourceclaim/controller.go index 596113b17d2..b810987608f 100644 --- a/pkg/controller/resourceclaim/controller.go +++ b/pkg/controller/resourceclaim/controller.go @@ -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 } diff --git a/pkg/controller/resourceclaim/controller_test.go b/pkg/controller/resourceclaim/controller_test.go index 9921c88a198..7dce9f36c12 100644 --- a/pkg/controller/resourceclaim/controller_test.go +++ b/pkg/controller/resourceclaim/controller_test.go @@ -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},