@@ -1013,11 +1013,10 @@ func (sa *Application) tryAllocate(headRoom *resources.Resource, allowPreemption
10131013 // resource must fit in headroom otherwise skip the request (unless preemption could help)
10141014 if ! headRoom .FitInMaxUndef (request .GetAllocatedResource ()) {
10151015 // attempt preemption
1016- if allowPreemption && * preemptAttemptsRemaining > 0 {
1017- * preemptAttemptsRemaining --
1016+ if allowPreemption {
10181017 fullIterator := fullNodeIterator ()
10191018 if fullIterator != nil {
1020- if result , ok := sa .tryPreemption (headRoom , preemptionDelay , request , fullIterator , false ); ok {
1019+ if result , ok := sa .tryPreemption (headRoom , preemptionDelay , preemptAttemptsRemaining , request , fullIterator , false ); ok {
10211020 // preemption occurred, and possibly reservation
10221021 return result
10231022 }
@@ -1050,11 +1049,10 @@ func (sa *Application) tryAllocate(headRoom *resources.Resource, allowPreemption
10501049 }
10511050
10521051 // no nodes qualify, attempt preemption
1053- if allowPreemption && * preemptAttemptsRemaining > 0 {
1054- * preemptAttemptsRemaining --
1052+ if allowPreemption {
10551053 fullIterator := fullNodeIterator ()
10561054 if fullIterator != nil {
1057- if result , ok := sa .tryPreemption (headRoom , preemptionDelay , request , fullIterator , true ); ok {
1055+ if result , ok := sa .tryPreemption (headRoom , preemptionDelay , preemptAttemptsRemaining , request , fullIterator , true ); ok {
10581056 // preemption occurred, and possibly reservation
10591057 return result
10601058 }
@@ -1364,14 +1362,23 @@ func (sa *Application) tryReservedAllocate(headRoom *resources.Resource, nodeIte
13641362 return nil
13651363}
13661364
1367- func (sa * Application ) tryPreemption (headRoom * resources.Resource , preemptionDelay time.Duration , ask * Allocation , iterator NodeIterator , nodesTried bool ) (* AllocationResult , bool ) {
1365+ func (sa * Application ) tryPreemption (headRoom * resources.Resource , preemptionDelay time.Duration , preemptionAttemptsRemaining * int , ask * Allocation , iterator NodeIterator , nodesTried bool ) (* AllocationResult , bool ) {
1366+ if * preemptionAttemptsRemaining == 0 {
1367+ log .Log (log .SchedApplication ).Debug ("Max queue preemption attempts exhausted" ,
1368+ zap .String ("allocationKey" , ask .GetAllocationKey ()),
1369+ zap .String ("applicationID" , sa .ApplicationID ),
1370+ zap .String ("queue" , sa .queuePath ))
1371+ ask .LogAllocationFailure (common .PreemptionMaxAttemptsExhausted , true )
1372+ return nil , false
1373+ }
13681374 preemptor := NewPreemptor (sa , headRoom , preemptionDelay , ask , iterator , nodesTried )
13691375
13701376 // validate prerequisites for preemption of an ask and mark ask for preemption if successful
13711377 if ! preemptor .CheckPreconditions () {
13721378 ask .LogAllocationFailure (common .PreemptionPreconditionsFailed , true )
13731379 return nil , false
13741380 }
1381+ * preemptionAttemptsRemaining --
13751382
13761383 // track time spent trying preemption
13771384 tryPreemptionStart := time .Now ()
0 commit comments