mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +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
|
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
|
||||||
}
|
}
|
||||||
|
@ -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,
|
||||||
|
Loading…
Reference in New Issue
Block a user