mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 07:27:21 +00:00
Don't mark job as failed until expectations are satisfied
Change-Id: I99206f35f6f145054c005ab362c792e71b9b15f4
This commit is contained in:
@@ -725,7 +725,7 @@ func (jm *Controller) syncJob(ctx context.Context, key string) (forget bool, rEr
|
||||
// Check the expectations of the job before counting active pods, otherwise a new pod can sneak in
|
||||
// and update the expectations after we've retrieved active pods from the store. If a new pod enters
|
||||
// the store after we've checked the expectation, the job sync is just deferred till the next relist.
|
||||
jobNeedsSync := jm.expectations.SatisfiedExpectations(key)
|
||||
satisfiedExpectations := jm.expectations.SatisfiedExpectations(key)
|
||||
|
||||
pods, err := jm.getPodsForJob(ctx, &job, uncounted != nil)
|
||||
if err != nil {
|
||||
@@ -782,9 +782,9 @@ func (jm *Controller) syncJob(ctx context.Context, key string) (forget bool, rEr
|
||||
if uncounted == nil {
|
||||
// Legacy behavior: pretend all active pods were successfully removed.
|
||||
deleted = active
|
||||
} else if deleted != active {
|
||||
} else if deleted != active || !satisfiedExpectations {
|
||||
// Can't declare the Job as finished yet, as there might be remaining
|
||||
// pod finalizers.
|
||||
// pod finalizers or pods that are not in the informer's cache yet.
|
||||
finishedCondition = nil
|
||||
}
|
||||
active -= deleted
|
||||
@@ -792,7 +792,7 @@ func (jm *Controller) syncJob(ctx context.Context, key string) (forget bool, rEr
|
||||
manageJobErr = err
|
||||
} else {
|
||||
manageJobCalled := false
|
||||
if jobNeedsSync && job.DeletionTimestamp == nil {
|
||||
if satisfiedExpectations && job.DeletionTimestamp == nil {
|
||||
active, action, manageJobErr = jm.manageJob(ctx, &job, activePods, succeeded, succeededIndexes)
|
||||
manageJobCalled = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user