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

Fix pastBackoffLimitOnFailure in job controller
pull/58/head
k8s-ci-robot 2018-10-11 05:49:30 -07:00 committed by GitHub
commit e6c5fb4666
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -643,6 +643,9 @@ func pastBackoffLimitOnFailure(job *batch.Job, pods []*v1.Pod) bool {
result += stat.RestartCount result += stat.RestartCount
} }
} }
if *job.Spec.BackoffLimit == 0 {
return result > 0
}
return result >= *job.Spec.BackoffLimit return result >= *job.Spec.BackoffLimit
} }

View File

@ -1422,6 +1422,21 @@ func TestJobBackoffForOnFailure(t *testing.T) {
expectedCondition *batch.JobConditionType expectedCondition *batch.JobConditionType
expectedConditionReason string 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": { "too many job failures - single pod": {
1, 5, 2, 1, 5, 2,
true, []int32{2}, true, []int32{2},