@@ -345,6 +345,7 @@ func (qjm *XController) PreemptQueueJobs(inspectAw *arbv1.AppWrapper) {
345345 newjob .Status .CanRun = false
346346 newjob .Status .FilterIgnore = true // update QueueJobState only
347347 cleanAppWrapper := false
348+ generatedCondition := false
348349 // If dispatch deadline is exceeded no matter what the state of AW, kill the job and set status as Failed.
349350 if (newjob .Status .State == arbv1 .AppWrapperStateActive ) && (newjob .Spec .SchedSpec .DispatchDuration .Limit > 0 ) {
350351 if newjob .Spec .SchedSpec .DispatchDuration .Overrun {
@@ -372,6 +373,7 @@ func (qjm *XController) PreemptQueueJobs(inspectAw *arbv1.AppWrapper) {
372373 qjm .qjqueue .AddUnschedulableIfNotPresent (updateNewJob )
373374
374375 }
376+ generatedCondition = true
375377 }
376378
377379 if ((newjob .Status .Running + newjob .Status .Succeeded ) < int32 (newjob .Spec .SchedSpec .MinAvailable )) && newjob .Status .State == arbv1 .AppWrapperStateActive {
@@ -412,7 +414,8 @@ func (qjm *XController) PreemptQueueJobs(inspectAw *arbv1.AppWrapper) {
412414 }
413415
414416 updateNewJob = newjob .DeepCopy ()
415- } else {
417+ generatedCondition = true
418+ } else if newjob .Status .Running == 0 && newjob .Status .Succeeded == 0 && newjob .Status .State == arbv1 .AppWrapperStateActive {
416419 // If pods failed scheduling generate new preempt condition
417420 message = fmt .Sprintf ("Pods failed scheduling failed=%v, running=%v." , len (newjob .Status .PendingPodConditions ), newjob .Status .Running )
418421 index := getIndexOfMatchedCondition (newjob , arbv1 .AppWrapperCondPreemptCandidate , "PodsFailedScheduling" )
@@ -427,13 +430,15 @@ func (qjm *XController) PreemptQueueJobs(inspectAw *arbv1.AppWrapper) {
427430 }
428431
429432 updateNewJob = newjob .DeepCopy ()
433+ generatedCondition = true
430434 }
431435
432- err = qjm .updateStatusInEtcdWithRetry (ctx , updateNewJob , "PreemptQueueJobs - CanRun: false -- MinPodsNotRunning" )
433- if err != nil {
434- klog .Warningf ("[PreemptQueueJobs] status update for '%s/%s' failed, skipping app wrapper err =%v" , newjob .Namespace , newjob .Name , err )
435- return
436- }
436+ if generatedCondition {
437+ err = qjm .updateStatusInEtcdWithRetry (ctx , updateNewJob , "PreemptQueueJobs - CanRun: false -- MinPodsNotRunning" )
438+ if err != nil {
439+ klog .Warningf ("[PreemptQueueJobs] status update for '%s/%s' failed, skipping app wrapper err =%v" , newjob .Namespace , newjob .Name , err )
440+ return
441+ }
437442
438443 if cleanAppWrapper {
439444 klog .V (4 ).Infof ("[PreemptQueueJobs] Deleting AppWrapper %s/%s due to maximum number of re-queueing(s) exceeded." , newjob .Namespace , newjob .Name )
0 commit comments