Unverified Commit e6c5fb46 authored by k8s-ci-robot's avatar k8s-ci-robot Committed by GitHub

Merge pull request #67859 from goodluckbot/job-controller-backoffLimit

Fix pastBackoffLimitOnFailure in job controller
parents 8f620950 53c3e103
......@@ -643,6 +643,9 @@ func pastBackoffLimitOnFailure(job *batch.Job, pods []*v1.Pod) bool {
result += stat.RestartCount
}
}
if *job.Spec.BackoffLimit == 0 {
return result > 0
}
return result >= *job.Spec.BackoffLimit
}
......
......@@ -1422,6 +1422,21 @@ func TestJobBackoffForOnFailure(t *testing.T) {
expectedCondition *batch.JobConditionType
expectedConditionReason string
}{
"backoffLimit 0 should have 1 pod active": {
1, 1, 0,
true, []int32{0},
1, 0, 0, nil, "",
},
"backoffLimit 1 with restartCount 0 should have 1 pod active": {
1, 1, 1,
true, []int32{0},
1, 0, 0, nil, "",
},
"backoffLimit 1 with restartCount 1 should have 0 pod active": {
1, 1, 1,
true, []int32{1},
0, 0, 1, &jobConditionFailed, "BackoffLimitExceeded",
},
"too many job failures - single pod": {
1, 5, 2,
true, []int32{2},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment