dra resourceclaim controller: delete generated claims when pod is done

When a pod is done, but not getting removed yet for while, then a claim that
got generated for that pod can be deleted already. This then also triggers
deallocation.
This commit is contained in:
Patrick Ohly
2023-06-22 14:15:17 +02:00
parent e8a0c42212
commit a514f40131
4 changed files with 92 additions and 1 deletions

View File

@@ -216,6 +216,18 @@ func TestSyncHandler(t *testing.T) {
expectedClaims: []resourcev1alpha2.ResourceClaim{*testClaimReserved},
expectedMetrics: expectedMetrics{0, 0},
},
{
name: "delete-claim-when-done",
pods: func() []*v1.Pod {
pods := []*v1.Pod{testPodWithResource.DeepCopy()}
pods[0].Status.Phase = v1.PodSucceeded
return pods
}(),
key: claimKey(testClaimReserved),
claims: []*resourcev1alpha2.ResourceClaim{testClaimReserved},
expectedClaims: nil,
expectedMetrics: expectedMetrics{0, 0},
},
}
for _, tc := range tests {