File tree Expand file tree Collapse file tree 2 files changed +2
-21
lines changed
cluster-autoscaler/simulator/dynamicresources Expand file tree Collapse file tree 2 files changed +2
-21
lines changed Original file line number Diff line number Diff line change @@ -152,7 +152,7 @@ func (s *Snapshot) RemovePodOwnedClaims(pod *apiv1.Pod) {
152
152
153
153
for _ , claim := range claims {
154
154
claimId := GetClaimId (claim )
155
- if drautils . PodOwnsClaim (pod , claim ) {
155
+ if err := resourceclaim . IsForPod (pod , claim ); err == nil {
156
156
s .resourceClaims .DeleteCurrent (claimId )
157
157
continue
158
158
}
@@ -201,7 +201,7 @@ func (s *Snapshot) UnreservePodClaims(pod *apiv1.Pod) error {
201
201
claimId := GetClaimId (claim )
202
202
claim := s .ensureClaimWritable (claim )
203
203
drautils .ClearPodReservationInPlace (claim , pod )
204
- if drautils . PodOwnsClaim (pod , claim ) || ! drautils .ClaimInUse (claim ) {
204
+ if err := resourceclaim . IsForPod (pod , claim ); err == nil || ! drautils .ClaimInUse (claim ) {
205
205
drautils .DeallocateClaimInPlace (claim )
206
206
}
207
207
Original file line number Diff line number Diff line change @@ -22,29 +22,10 @@ import (
22
22
apiv1 "k8s.io/api/core/v1"
23
23
resourceapi "k8s.io/api/resource/v1beta1"
24
24
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
25
- "k8s.io/apimachinery/pkg/types"
26
25
"k8s.io/component-helpers/scheduling/corev1"
27
26
"k8s.io/dynamic-resource-allocation/resourceclaim"
28
- "k8s.io/utils/ptr"
29
27
)
30
28
31
- // ClaimOwningPod returns the name and UID of the Pod owner of the provided claim. If the claim isn't
32
- // owned by a Pod, empty strings are returned.
33
- func ClaimOwningPod (claim * resourceapi.ResourceClaim ) (string , types.UID ) {
34
- for _ , owner := range claim .OwnerReferences {
35
- if ptr .Deref (owner .Controller , false ) && owner .APIVersion == "v1" && owner .Kind == "Pod" {
36
- return owner .Name , owner .UID
37
- }
38
- }
39
- return "" , ""
40
- }
41
-
42
- // PodOwnsClaim determines if the provided pod is the controller of the given claim.
43
- func PodOwnsClaim (pod * apiv1.Pod , claim * resourceapi.ResourceClaim ) bool {
44
- ownerPodName , ownerPodUid := ClaimOwningPod (claim )
45
- return ownerPodName == pod .Name && ownerPodUid == pod .UID
46
- }
47
-
48
29
// ClaimAllocated returns whether the provided claim is allocated.
49
30
func ClaimAllocated (claim * resourceapi.ResourceClaim ) bool {
50
31
return claim .Status .Allocation != nil
You can’t perform that action at this time.
0 commit comments