mirror of https://github.com/k3s-io/k3s
Merge pull request #67859 from goodluckbot/job-controller-backoffLimit
Fix pastBackoffLimitOnFailure in job controllerpull/58/head
commit
e6c5fb4666
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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},
|
||||||
|
|
Loading…
Reference in New Issue