@@ -1178,7 +1178,7 @@ func (jm *Controller) trackJobStatusAndRemoveFinalizers(ctx context.Context, job
1178
1178
if jobCtx .job , needsFlush , err = jm .flushUncountedAndRemoveFinalizers (ctx , jobCtx , podsToRemoveFinalizer , uidsWithFinalizer , & oldCounters , podFailureCountByPolicyAction , needsFlush ); err != nil {
1179
1179
return err
1180
1180
}
1181
- jobFinished := ! reachedMaxUncountedPods && jm .enactJobFinished (jobCtx . job , jobCtx . finishedCondition )
1181
+ jobFinished := ! reachedMaxUncountedPods && jm .enactJobFinished (logger , jobCtx )
1182
1182
if jobFinished {
1183
1183
needsFlush = true
1184
1184
}
@@ -1353,15 +1353,18 @@ func (jm *Controller) removeTrackingFinalizerFromPods(ctx context.Context, jobKe
1353
1353
1354
1354
// enactJobFinished adds the Complete or Failed condition and records events.
1355
1355
// Returns whether the Job was considered finished.
1356
- func (jm * Controller ) enactJobFinished (job * batch. Job , finishedCond * batch. JobCondition ) bool {
1357
- if finishedCond == nil {
1356
+ func (jm * Controller ) enactJobFinished (logger klog. Logger , jobCtx * syncJobCtx ) bool {
1357
+ if jobCtx . finishedCondition == nil {
1358
1358
return false
1359
1359
}
1360
+ job := jobCtx .job
1360
1361
if uncounted := job .Status .UncountedTerminatedPods ; uncounted != nil {
1361
- if len (uncounted .Succeeded ) > 0 || len (uncounted .Failed ) > 0 {
1362
+ if count := len (uncounted .Succeeded ) + len (uncounted .Failed ); count > 0 {
1363
+ logger .V (4 ).Info ("Delaying marking the Job as finished, because there are still uncounted pod(s)" , "job" , klog .KObj (job ), "condition" , jobCtx .finishedCondition .Type , "count" , count )
1362
1364
return false
1363
1365
}
1364
1366
}
1367
+ finishedCond := jobCtx .finishedCondition
1365
1368
job .Status .Conditions , _ = ensureJobConditionStatus (job .Status .Conditions , finishedCond .Type , finishedCond .Status , finishedCond .Reason , finishedCond .Message , jm .clock .Now ())
1366
1369
if finishedCond .Type == batch .JobComplete {
1367
1370
job .Status .CompletionTime = & finishedCond .LastTransitionTime
0 commit comments