Skip to content

Commit c49b140

Browse files
authored
Merge pull request kubernetes#125175 from dejanzele/feat/count-terminating-for-failed-jobs
Count terminating pods when deleting active pods for failed jobs
2 parents a7ca13e + 01536f5 commit c49b140

File tree

3 files changed

+312
-50
lines changed

3 files changed

+312
-50
lines changed

pkg/controller/job/job_controller.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,9 @@ func (jm *Controller) syncJob(ctx context.Context, key string) (rErr error) {
896896
jobCtx.finishedCondition = nil
897897
}
898898
active -= deleted
899+
if feature.DefaultFeatureGate.Enabled(features.JobPodReplacementPolicy) {
900+
*jobCtx.terminating += deleted
901+
}
899902
manageJobErr = err
900903
} else {
901904
manageJobCalled := false
@@ -1501,6 +1504,9 @@ func (jm *Controller) manageJob(ctx context.Context, job *batch.Job, jobCtx *syn
15011504
jm.expectations.ExpectDeletions(logger, jobKey, len(podsToDelete))
15021505
removed, err := jm.deleteJobPods(ctx, job, jobKey, podsToDelete)
15031506
active -= removed
1507+
if feature.DefaultFeatureGate.Enabled(features.JobPodReplacementPolicy) {
1508+
*jobCtx.terminating += removed
1509+
}
15041510
return active, metrics.JobSyncActionPodsDeleted, err
15051511
}
15061512

@@ -1550,6 +1556,9 @@ func (jm *Controller) manageJob(ctx context.Context, job *batch.Job, jobCtx *syn
15501556
logger.V(4).Info("Too many pods running for job", "job", klog.KObj(job), "deleted", len(podsToDelete), "target", wantActive)
15511557
removed, err := jm.deleteJobPods(ctx, job, jobKey, podsToDelete)
15521558
active -= removed
1559+
if feature.DefaultFeatureGate.Enabled(features.JobPodReplacementPolicy) {
1560+
*jobCtx.terminating += removed
1561+
}
15531562
// While it is possible for a Job to require both pod creations and
15541563
// deletions at the same time (e.g. indexed Jobs with repeated indexes), we
15551564
// restrict ourselves to either just pod deletion or pod creation in any

0 commit comments

Comments
 (0)