mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Merge pull request #127397 from kannon92/cleanup-dra-deterministic-name
remove 1.27 deterministic support for resource claims
This commit is contained in:
		@@ -678,23 +678,20 @@ func (ec *Controller) findPodResourceClaim(pod *v1.Pod, podClaim v1.PodResourceC
 | 
				
			|||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	deterministicName := pod.Name + "-" + podClaim.Name // Kubernetes <= 1.27 behavior.
 | 
					 | 
				
			||||||
	for _, claimObj := range claims {
 | 
						for _, claimObj := range claims {
 | 
				
			||||||
		claim, ok := claimObj.(*resourceapi.ResourceClaim)
 | 
							claim, ok := claimObj.(*resourceapi.ResourceClaim)
 | 
				
			||||||
		if !ok {
 | 
							if !ok {
 | 
				
			||||||
			return nil, fmt.Errorf("unexpected object of type %T returned by claim cache", claimObj)
 | 
								return nil, fmt.Errorf("unexpected object of type %T returned by claim cache", claimObj)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		podClaimName, ok := claim.Annotations[podResourceClaimAnnotation]
 | 
							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
 | 
								continue
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// No annotation? It might a ResourceClaim created for
 | 
							// Not the claim for this particular pod claim?
 | 
				
			||||||
		// the pod with a previous Kubernetes release where the
 | 
							if podClaimName != podClaim.Name {
 | 
				
			||||||
		// 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 {
 | 
					 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -190,19 +190,6 @@ func TestSyncHandler(t *testing.T) {
 | 
				
			|||||||
			},
 | 
								},
 | 
				
			||||||
			expectedMetrics: expectedMetrics{0, 0},
 | 
								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",
 | 
								name:          "find-created-claim-in-cache",
 | 
				
			||||||
			pods:          []*v1.Pod{testPodWithResource},
 | 
								pods:          []*v1.Pod{testPodWithResource},
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user