pbacsko commented on code in PR #563:
URL: https://github.com/apache/yunikorn-core/pull/563#discussion_r1228165826


##########
pkg/common/configs/configvalidator.go:
##########
@@ -153,6 +219,56 @@ func checkQueueMaxApplications(cur QueueConfig) error {
        return nil
 }
 
+func checkLimitMaxApplications(cur QueueConfig, parent *QueueConfig, users 
map[string]uint64, groups map[string]uint64) error {
+       // Collect user and group limits of parent queue
+       if parent != nil {
+               for _, limit := range parent.Limits {
+                       for _, user := range limit.Users {
+                               users[user] = limit.MaxApplications
+                       }
+                       for _, group := range limit.Groups {
+                               groups[group] = limit.MaxApplications
+                       }
+               }
+       }
+
+       // compare user & group limit setting between the current queue and 
parent queue
+       for _, limit := range cur.Limits {
+               for _, user := range limit.Users {
+                       curM := limit.MaxApplications
+                       // Is user limit setting exists?
+                       if _, ok := users[user]; ok {
+                               if users[user] != 0 && (users[user] < curM || 
curM == 0) {
+                                       return fmt.Errorf("user %s max 
applications %v of queue %s is greater than immediate or ancestor parent max 
applications %v", user, curM, cur.Name, users[user])
+                               }
+                               users[user] = uint64(math.Min(float64(curM), 
float64(users[user])))
+                       } else {
+                               users[user] = curM
+                       }
+               }
+               for _, group := range limit.Groups {
+                       curM := limit.MaxApplications
+                       // Is group limit setting exists?
+                       if _, ok := groups[group]; ok {
+                               if groups[group] != 0 && (groups[group] < curM 
|| curM == 0) {
+                                       return fmt.Errorf("group %s max 
applications %v of queue %s is greater than immediate or ancestor parent max 
applications %v", group, curM, cur.Name, groups[group])
+                               }
+                               groups[group] = uint64(math.Min(float64(curM), 
float64(groups[group])))

Review Comment:
   `Min()` as Wilfred asked.



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