kingamarton commented on a change in pull request #219:
URL: 
https://github.com/apache/incubator-yunikorn-core/pull/219#discussion_r542329704



##########
File path: pkg/common/configs/configvalidator.go
##########
@@ -75,65 +75,100 @@ func checkACL(acl string) error {
 // Check the queue resource configuration settings.
 // - child or children cannot have higher maximum or guaranteed limits than 
parents
 // - children (added together) cannot have a higher guaranteed setting than a 
parent
-func checkResourceConfigurationsForQueue(cur *QueueConfig, parent 
*QueueConfig) error {
+func checkResourceConfigurationsForQueue(cur QueueConfig, parentMax 
*resources.Resource, parentGuaranteed *resources.Resource) error {
        // If cur has children, make sure sum of children's guaranteed <= 
cur.guaranteed
-       curGuaranteedRes, err := 
resources.NewResourceFromConf(cur.Resources.Guaranteed)
+       actualGuaranteed, err := 
resources.NewResourceFromConf(cur.Resources.Guaranteed)
        if err != nil {
                return err
        }
-       if curGuaranteedRes.HasNegativeValue() {
-               return fmt.Errorf("invalid guaranteed resource %v for queue %s, 
cannot be negative", curGuaranteedRes, cur.Name)
+       if actualGuaranteed.HasNegativeValue() {
+               return fmt.Errorf("invalid guaranteed resource %v for queue %s, 
cannot be negative", actualGuaranteed, cur.Name)
        }
-       curMaxRes, err := resources.NewResourceFromConf(cur.Resources.Max)
+       actualMax, err := resources.NewResourceFromConf(cur.Resources.Max)
        if err != nil {
                return err
        }
-       if curMaxRes.HasNegativeValue() {
-               return fmt.Errorf("invalid max resource %v for queue %s, cannot 
be negative", curMaxRes, cur.Name)
+       if actualMax.HasNegativeValue() {
+               return fmt.Errorf("invalid max resource %v for queue %s, cannot 
be negative", actualMax, cur.Name)
        }
 
+       maxToPass := resources.ComponentWiseMinPermissive(actualMax, parentMax)
+       guaranteedToPass := resources.ComponentWiseMinPermissive(maxToPass, 
actualGuaranteed)
+
        if len(cur.Queues) > 0 {
                // Check children
                for i := range cur.Queues {
-                       if err := 
checkResourceConfigurationsForQueue(&cur.Queues[i], cur); err != nil {
+                       if err = 
checkResourceConfigurationsForQueue(cur.Queues[i], maxToPass, 
guaranteedToPass); err != nil {
                                return err
                        }
                }
-               sum := resources.NewResource()
-               for _, child := range cur.Queues {
-                       childGuaranteed, err := 
resources.NewResourceFromConf(child.Resources.Guaranteed)
-                       if err != nil {
-                               return err
-                       }
-                       sum.AddTo(childGuaranteed)
+               err = checkGuaranteedResource(cur.Queues, actualGuaranteed, 
parentGuaranteed, cur.Name)
+               if err != nil {
+                       return err
                }
+       }
 
-               if cur.Resources.Guaranteed != nil {
-                       if !resources.FitIn(curGuaranteedRes, sum) {
-                               return fmt.Errorf("queue %s has 
guaranteed-resources (%v) smaller than sum of children guaranteed resources 
(%v)", cur.Name, curGuaranteedRes, sum)
-                       }
-               } else {
-                       cur.Resources.Guaranteed = sum.ToConf()

Review comment:
       reverted that func




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

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


Reply via email to