mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 12:32:03 +00:00
dra resourceclaim controller: refactor isPodDone
This covers pods that get deleted before running and will be used more than once soon.
This commit is contained in:
parent
bbc7ca94a4
commit
d1ba893ad8
@ -167,10 +167,7 @@ func (ec *Controller) enqueuePod(obj interface{}, deleted bool) {
|
||||
}
|
||||
|
||||
// Release reservations of a deleted or completed pod?
|
||||
if deleted ||
|
||||
podutil.IsPodTerminal(pod) ||
|
||||
// Deleted and not scheduled:
|
||||
pod.DeletionTimestamp != nil && pod.Spec.NodeName == "" {
|
||||
if deleted || isPodDone(pod) {
|
||||
for _, podClaim := range pod.Spec.ResourceClaims {
|
||||
claimName := resourceclaim.Name(pod, &podClaim)
|
||||
ec.queue.Add(claimKeyPrefix + pod.Namespace + "/" + claimName)
|
||||
@ -481,3 +478,10 @@ func podResourceClaimIndexFunc(obj interface{}) ([]string, error) {
|
||||
}
|
||||
return keys, nil
|
||||
}
|
||||
|
||||
// isPodDone returns true if it is certain that none of the containers are running and never will run.
|
||||
func isPodDone(pod *v1.Pod) bool {
|
||||
return podutil.IsPodPhaseTerminal(pod.Status.Phase) ||
|
||||
// Deleted and not scheduled:
|
||||
pod.DeletionTimestamp != nil && pod.Spec.NodeName == ""
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user