Merge pull request #103644 from alculquicondor/tracking-deleted-pods

Revert counting deleted pods as failures for Job
This commit is contained in:
Kubernetes Prow Robot 2021-07-14 09:02:28 -07:00 committed by GitHub
commit 68922e3deb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 3 deletions

View File

@ -1143,9 +1143,13 @@ func getStatus(job *batch.Job, pods []*v1.Pod, uncounted *uncountedTerminatedPod
return p.Status.Phase == v1.PodSucceeded return p.Status.Phase == v1.PodSucceeded
})) }))
failed += int32(countValidPodsWithFilter(job, pods, uncounted.Failed(), func(p *v1.Pod) bool { failed += int32(countValidPodsWithFilter(job, pods, uncounted.Failed(), func(p *v1.Pod) bool {
// Counting deleted Pods as failures to account for orphan Pods that never if p.Status.Phase == v1.PodFailed {
// have a chance to reach the Failed phase. return true
return p.Status.Phase == v1.PodFailed || (p.DeletionTimestamp != nil && p.Status.Phase != v1.PodSucceeded) }
// 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 return succeeded, failed
} }

View File

@ -1066,6 +1066,16 @@ func TestGetStatus(t *testing.T) {
wantFailed: 4, wantFailed: 4,
}, },
"deleted pods": { "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{ job: batch.Job{
Status: batch.JobStatus{ Status: batch.JobStatus{
Succeeded: 1, Succeeded: 1,