wilfred-s commented on code in PR #1103:
URL: https://github.com/apache/yunikorn-core/pull/1103#discussion_r3576141325


##########
pkg/scheduler/objects/preemption.go:
##########
@@ -158,38 +159,48 @@ func (p *Preemptor) initWorkingState() {
                        queueByAlloc[allocation.GetAllocationKey()] = victims
                }
        }
-
+       // total reservation cancelled to make sure we update the global 
counters
+       totalReservationCancel := 0
        // walk node iterator and track available resources per node
        p.iterator.ForEachNode(func(node *Node) bool {
-               hasOtherReservations := false
+               isReserved := false
                if node.IsReserved() && 
!node.isReservedForAllocation(p.ask.GetAllocationKey()) {
-                       hasOtherReservations = true
+                       leftCount := 0
                        for _, res := range node.GetReservations() {
+                               leftCount++
                                // Is Allocation daemon set?
                                // Has this allocation already triggered 
preemption?
                                if res.alloc.requiredNode != "" || 
res.alloc.HasTriggeredPreemption() {
                                        continue
                                }
-                               createTime := res.alloc.GetCreateTime()
-                               // Take reservation delay also into account
-                               askAge := 
time.Since(createTime.Add(reservationWaitTimeout).Add(reservationDelay))
-
                                // Cancel reservation based on its priority and 
waiting time in reservation queue
-                               if res.alloc.GetPriority() < p.ask.priority && 
askAge > reservationWaitTimeout {
-                                       num := res.app.UnReserve(res.node, 
res.alloc)
-                                       
res.app.GetQueue().UnReserve(res.app.ApplicationID, num)
-                                       
log.Log(log.SchedApplication).Info("Cancelled reservation to consider node for 
preemption",
-                                               zap.String("triggered by 
appID", p.application.ApplicationID),
-                                               zap.String("triggered by 
allocationKey", p.ask.allocationKey),
-                                               zap.String("affected 
application ID", res.appID),
-                                               zap.String("affected 
allocationKey", res.allocKey),
-                                               zap.String("node", res.nodeID),
-                                               zap.Int("reservations count", 
num))
-                                       hasOtherReservations = false
+                               if res.alloc.GetPriority() < p.ask.priority && 
time.Since(res.createTime) > reservationWaitTimeout {
+                                       
log.Log(log.SchedPreemption).Info("Cancelling reservation to consider node for 
preemption",
+                                               zap.String("triggeringAppID", 
p.application.ApplicationID),
+                                               
zap.String("triggeringAllocationKey", p.ask.allocationKey),
+                                               zap.String("reservingAppID", 
res.appID),
+                                               
zap.String("reservingAllocationKey", res.allocKey),
+                                               zap.String("node", node.NodeID))
+                                       num := 0

Review Comment:
   [YUNIKORN-3319 ](https://issues.apache.org/jira/browse/YUNIKORN-3319) has 
the details



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to