mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #103644 from alculquicondor/tracking-deleted-pods
Revert counting deleted pods as failures for Job
This commit is contained in:
commit
68922e3deb
@ -1143,9 +1143,13 @@ func getStatus(job *batch.Job, pods []*v1.Pod, uncounted *uncountedTerminatedPod
|
||||
return p.Status.Phase == v1.PodSucceeded
|
||||
}))
|
||||
failed += int32(countValidPodsWithFilter(job, pods, uncounted.Failed(), func(p *v1.Pod) bool {
|
||||
// Counting deleted Pods as failures to account for orphan Pods that never
|
||||
// have a chance to reach the Failed phase.
|
||||
return p.Status.Phase == v1.PodFailed || (p.DeletionTimestamp != nil && p.Status.Phase != v1.PodSucceeded)
|
||||
if p.Status.Phase == v1.PodFailed {
|
||||
return true
|
||||
}
|
||||
// When tracking with finalizers: counting deleted Pods as failures to
|
||||
// account for orphan Pods that never have a chance to reach the Failed
|
||||
// phase.
|
||||
return uncounted != nil && p.DeletionTimestamp != nil && p.Status.Phase != v1.PodSucceeded
|
||||
}))
|
||||
return succeeded, failed
|
||||
}
|
||||
|
@ -1066,6 +1066,16 @@ func TestGetStatus(t *testing.T) {
|
||||
wantFailed: 4,
|
||||
},
|
||||
"deleted pods": {
|
||||
pods: []*v1.Pod{
|
||||
buildPod().uid("a").phase(v1.PodSucceeded).deletionTimestamp().Pod,
|
||||
buildPod().uid("b").phase(v1.PodFailed).deletionTimestamp().Pod,
|
||||
buildPod().uid("c").phase(v1.PodRunning).deletionTimestamp().Pod,
|
||||
buildPod().uid("d").phase(v1.PodPending).deletionTimestamp().Pod,
|
||||
},
|
||||
wantSucceeded: 1,
|
||||
wantFailed: 1,
|
||||
},
|
||||
"deleted pods, tracking with finalizers": {
|
||||
job: batch.Job{
|
||||
Status: batch.JobStatus{
|
||||
Succeeded: 1,
|
||||
|
Loading…
Reference in New Issue
Block a user