manirajv06 commented on code in PR #926:
URL: https://github.com/apache/yunikorn-core/pull/926#discussion_r1705070849


##########
pkg/scheduler/ugm/queue_tracker.go:
##########
@@ -403,24 +403,20 @@ func (qt *QueueTracker) canRunApp(hierarchy []string, 
applicationID string, trac
 // it decides the removal. It returns false the moment it sees any unexpected 
values for any queue in any levels.
 // Note: Lock free call. The RLock of the linked tracker (UserTracker and 
GroupTracker) should be held before calling this function.
 func (qt *QueueTracker) canBeRemoved() bool {
-       for _, childQT := range qt.childQueueTrackers {
-               // quick check to avoid further traversal
-               if childQT.canBeRemovedInternal() {
+       if len(qt.childQueueTrackers) > 0 {
+               for _, childQT := range qt.childQueueTrackers {
+                       // quick check to avoid further traversal
                        if !childQT.canBeRemoved() {
                                return false
                        }
-               } else {
-                       return false
                }
+               return true // removable because all children are removable
        }
-       // reached leaf queues, no more to traverse
-       return qt.canBeRemovedInternal()
-}
 
-func (qt *QueueTracker) canBeRemovedInternal() bool {
-       if len(qt.runningApplications) == 0 && 
resources.IsZero(qt.resourceUsage) && len(qt.childQueueTrackers) == 0 &&
-               qt.maxRunningApps == 0 && resources.IsZero(qt.maxResources) {
-               return true
-       }
-       return false
+       // reached a leaf queue
+       return len(qt.runningApplications) == 0 &&
+               resources.IsZero(qt.resourceUsage) &&
+               len(qt.childQueueTrackers) == 0 &&
+               qt.maxRunningApps == 0 &&
+               resources.IsZero(qt.maxResources)

Review Comment:
   In newer approach, we take decision only after reaching the leaf queue by 
traversing all the queues in the queue hierarchy. Whereas earlier, earlier one 
takes decision at very earlier stage and come out then and there.



-- 
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