pbacsko commented on a change in pull request #384:
URL: 
https://github.com/apache/incubator-yunikorn-core/pull/384#discussion_r824578541



##########
File path: pkg/scheduler/objects/application.go
##########
@@ -1264,6 +1264,9 @@ func (sa *Application) AddAllocation(info *Allocation) {
 // Add the Allocation to the application
 // No locking must be called while holding the lock
 func (sa *Application) addAllocationInternal(info *Allocation) {
+       if sa.queue != nil && sa.queue.maxRunningApps != 0 && 
sa.stateMachine.Is(Accepted.String()) && sa.queue.maxRunningApps <= 
sa.queue.runningApps {
+               return

Review comment:
       As @wilfred-s mentioned in the JIRA, we have to have a `CanRun()` method 
in the queue, something like:
   
   ```
   func (sq *Queue) CanRun() {
        sq.RLock()
        defer sq.RUnlock()
        
           if sq.maxRunningApps == 0 {
             return true
           }
   
        ok := sq.runningApps < sq.maxRunningApps
        if sq.parent != nil {
                return ok && sq.parent.CanRun()
        } else {
                return ok
        }
   }
   ```
   
   so then it becomes simpler:
   ```
   if sa.queue != nil && sa.stateMachine.Is(Accepted.String()) && 
sa.queue.CanRun() {
   ...
   } else {
     // maxRunningApps reached, save the Application
     ...
   }
   ```




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