Skip to content

Commit 6d70013

Browse files
authored
Merge pull request kubernetes#121147 from kannon92/rm-at-least-no-terminating-count
Remove terminating count from rmAtLeast
2 parents 613f759 + 7a1ac18 commit 6d70013

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

pkg/controller/job/job_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1494,7 +1494,7 @@ func (jm *Controller) manageJob(ctx context.Context, job *batch.Job, jobCtx *syn
14941494
}
14951495
}
14961496

1497-
rmAtLeast := active + terminating - wantActive
1497+
rmAtLeast := active - wantActive
14981498
if rmAtLeast < 0 {
14991499
rmAtLeast = 0
15001500
}

pkg/controller/job/job_controller_test.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,10 @@ func TestControllerSyncJob(t *testing.T) {
362362
jobPodReplacementPolicy: true,
363363
terminatingPods: 1,
364364
expectedTerminating: ptr.To[int32](1),
365-
expectedPodPatches: 2,
366-
expectedDeletions: 1,
367-
expectedFailed: 1,
365+
// Removes finalizer and deletes one failed pod
366+
expectedPodPatches: 1,
367+
expectedFailed: 1,
368+
expectedActive: 1,
368369
},
369370
"WQ job: turn on PodReplacementPolicy but not set PodReplacementPolicy": {
370371
parallelism: 1,
@@ -393,7 +394,20 @@ func TestControllerSyncJob(t *testing.T) {
393394
expectedPodPatches: 2,
394395
expectedFailed: 2,
395396
},
396-
397+
"more terminating pods than parallelism": {
398+
parallelism: 1,
399+
completions: 1,
400+
backoffLimit: 6,
401+
activePods: 2,
402+
failedPods: 0,
403+
terminatingPods: 4,
404+
podReplacementPolicy: podReplacementPolicy(batch.Failed),
405+
jobPodReplacementPolicy: true,
406+
expectedTerminating: ptr.To[int32](4),
407+
expectedActive: 1,
408+
expectedDeletions: 1,
409+
expectedPodPatches: 1,
410+
},
397411
"too few active pods and active back-off": {
398412
parallelism: 1,
399413
completions: 1,

0 commit comments

Comments
 (0)