FrankYang0529 commented on code in PR #760:
URL: https://github.com/apache/yunikorn-core/pull/760#discussion_r1433911028


##########
pkg/common/configs/configvalidator.go:
##########
@@ -232,54 +232,53 @@ func checkLimitMaxApplications(cur QueueConfig, users 
map[string]map[string]uint
                curQueuePath = queuePath + DOT + cur.Name
        }
 
-       // Carry forward (populate) the parent limit settings to the next level 
if limits are not configured for the current queue
-       if len(cur.Limits) == 0 {
-               if _, ok := users[queuePath]; ok {
-                       users[curQueuePath] = users[queuePath]
-               }
-               if _, ok := groups[queuePath]; ok {
-                       groups[curQueuePath] = groups[queuePath]
-               }
-       } else {
-               // compare user & group limit setting between the current queue 
and parent queue
-               for _, limit := range cur.Limits {
-                       limitMaxApplications := limit.MaxApplications
-                       for _, user := range limit.Users {
-                               // Is user limit setting exists?
-                               if userMaxApplications, ok := 
users[queuePath][user]; ok {
-                                       if userMaxApplications != 0 && 
(userMaxApplications < limitMaxApplications || limitMaxApplications == 0) {
-                                               return fmt.Errorf("user %s max 
applications %d of queue %s is greater than immediate or ancestor parent max 
applications %d", user, limitMaxApplications, cur.Name, userMaxApplications)
-                                       }
-                                       // Override with min resource
-                                       if _, ok := users[curQueuePath]; !ok {
-                                               users[curQueuePath] = 
make(map[string]uint64)
-                                       }
-                                       users[curQueuePath][user] = 
common.Min(limitMaxApplications, userMaxApplications)
-                               } else {
-                                       if _, ok := users[curQueuePath]; !ok {
-                                               users[curQueuePath] = 
make(map[string]uint64)
-                                       }
-                                       users[curQueuePath][user] = 
limitMaxApplications
+       users[curQueuePath] = make(map[string]uint64)
+       groups[curQueuePath] = make(map[string]uint64)
+
+       // Carry forward (populate) the parent limit settings to the next level
+       for u, v := range users[queuePath] {
+               users[curQueuePath][u] = v
+       }
+       for g, v := range groups[queuePath] {
+               groups[curQueuePath][g] = v
+       }
+
+       // compare user & group limit setting between the current queue and 
parent queue
+       for _, limit := range cur.Limits {
+               limitMaxApplications := limit.MaxApplications
+               for _, user := range limit.Users {
+                       // Is user limit setting exists?
+                       if userMaxApplications, ok := users[queuePath][user]; 
ok {
+                               if userMaxApplications != 0 && 
(userMaxApplications < limitMaxApplications || limitMaxApplications == 0) {
+                                       return fmt.Errorf("user %s max 
applications %d of queue %s is greater than immediate or ancestor parent max 
applications %d", user, limitMaxApplications, cur.Name, userMaxApplications)
+                               }
+                               // Override with min resource
+                               users[curQueuePath][user] = 
common.Min(limitMaxApplications, userMaxApplications)
+                       } else if wildcardMaxApplications, ok := 
users[queuePath][common.Wildcard]; user != common.Wildcard && ok {
+                               if wildcardMaxApplications != 0 && 
(wildcardMaxApplications < limitMaxApplications || limitMaxApplications == 0) {
+                                       return fmt.Errorf("user %s max 
applications %d of queue %s is greater than wildcard max applications %d of 
immediate or ancestor parent queue", user, limitMaxApplications, cur.Name, 
wildcardMaxApplications)
                                }
+                               users[curQueuePath][user] = 
common.Min(limitMaxApplications, wildcardMaxApplications)

Review Comment:
   After double check, I think we can just use `limitMaxApplications`. The 
`wildcardMaxApplications` is like parent maxapplications and 
`limitMaxApplications` is like child, so we will have following cases:
   
   * parent == 0 and child == 0, this case is fine to assign child value.
   * parent != 0 and child == 0, throw error in line 258.
   * parent != 0 and child != 0, and parent > child, it's ok to assign child 
value.
   * parent != 0 and child != 0, and parent > child, throw error in line 258.
   * parent == 0 and child != 0, it's ok to assign child value.



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