mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 04:06:03 +00:00
Improves backoff policy in JobController
issues: https://github.com/kubernetes/kubernetes/issues/56853 Add check if the number of pods succeeded increased since the last check. If yes the backoff delay is cleared. This logic improves the Job backoff policy when parallelism > 1 and few pods's Job failed but others succeed.
This commit is contained in:
parent
551f73d324
commit
c6e8bd62ad
@ -553,6 +553,14 @@ func (jm *JobController) syncJob(key string) (bool, error) {
|
||||
}
|
||||
|
||||
forget := false
|
||||
// Check if the number of jobs succeeded increased since the last check. If yes "forget" should be true
|
||||
// This logic is linked to the issue: https://github.com/kubernetes/kubernetes/issues/56853 that aims to
|
||||
// improve the Job backoff policy when parallelism > 1 and few Jobs failed but others succeed.
|
||||
// In this case, we should clear the backoff delay.
|
||||
if job.Status.Succeeded < succeeded {
|
||||
forget = true
|
||||
}
|
||||
|
||||
// no need to update the job if the status hasn't changed since last time
|
||||
if job.Status.Active != active || job.Status.Succeeded != succeeded || job.Status.Failed != failed || len(job.Status.Conditions) != conditions {
|
||||
job.Status.Active = active
|
||||
@ -560,12 +568,12 @@ func (jm *JobController) syncJob(key string) (bool, error) {
|
||||
job.Status.Failed = failed
|
||||
|
||||
if err := jm.updateHandler(&job); err != nil {
|
||||
return false, err
|
||||
return forget, err
|
||||
}
|
||||
|
||||
if jobHaveNewFailure && !IsJobFinished(&job) {
|
||||
// returning an error will re-enqueue Job after the backoff period
|
||||
return false, fmt.Errorf("failed pod(s) detected for job key %q", key)
|
||||
return forget, fmt.Errorf("failed pod(s) detected for job key %q", key)
|
||||
}
|
||||
|
||||
forget = true
|
||||
|
@ -218,11 +218,16 @@ func TestControllerSyncJob(t *testing.T) {
|
||||
fmt.Errorf("Fake error"), true, 0, 3, 0, 0,
|
||||
0, 1, 3, 0, 0, nil, "",
|
||||
},
|
||||
"failed pod": {
|
||||
"failed + succeed pods: reset backoff delay": {
|
||||
2, 5, 6, false, 0,
|
||||
fmt.Errorf("Fake error"), false, 0, 1, 1, 1,
|
||||
fmt.Errorf("Fake error"), true, 0, 1, 1, 1,
|
||||
1, 0, 1, 1, 1, nil, "",
|
||||
},
|
||||
"only new failed pod": {
|
||||
2, 5, 6, false, 0,
|
||||
fmt.Errorf("Fake error"), false, 0, 1, 0, 1,
|
||||
1, 0, 1, 0, 1, nil, "",
|
||||
},
|
||||
"job finish": {
|
||||
2, 5, 6, false, 0,
|
||||
nil, true, 0, 0, 5, 0,
|
||||
|
Loading…
Reference in New Issue
Block a user