chia7712 commented on code in PR #763:
URL: https://github.com/apache/yunikorn-core/pull/763#discussion_r1439048840


##########
pkg/common/configs/configvalidator.go:
##########
@@ -734,7 +756,8 @@ func Validate(newConfig *SchedulerConfig) error {
 
        // check uniqueness
        partitionMap := make(map[string]bool)
-       for i, partition := range newConfig.Partitions {
+       for i := range newConfig.Partitions {
+               partition := newConfig.Partitions[i]

Review Comment:
   It seems this change is redundant?



##########
pkg/common/configs/configvalidator.go:
##########
@@ -706,7 +728,7 @@ func checkQueuesStructure(partition *PartitionConfig) error 
{
        if rootQueue.Resources.Guaranteed != nil || rootQueue.Resources.Max != 
nil {
                return fmt.Errorf("root queue must not have resource limits 
set")
        }
-       return checkQueues(&rootQueue, 1)
+       return nil

Review Comment:
   pardon, is this change related to this PR?



##########
pkg/common/configs/config_test.go:
##########
@@ -907,15 +907,15 @@ partitions:
        conf, err := CreateConfig(data)
        assert.NilError(t, err, "partition user parsing should not have failed")
        // gone through validation: 1 top level queues
-       if len(conf.Partitions[0].Queues) != 1 {
-               t.Errorf("failed to load queue %v", conf)
+       if len(conf.Partitions[0].Queues) != 1 || 
len(conf.Partitions[0].Queues[0].Limits) != 3 {
+               t.Errorf("partition limits not correctly applied to root queue 
%v", conf)
        }
-       if len(conf.Partitions[0].Limits) != 3 {
-               t.Errorf("partition users linked not correctly loaded  %v", 
conf)
+       if len(conf.Partitions[0].Limits) != 0 {
+               t.Errorf("partition limits not wiped out %v", conf)
        }
 
        // limit 1 check
-       limit := conf.Partitions[0].Limits[0]
+       limit := conf.Partitions[0].Queues[0].Limits[0]

Review Comment:
   ok, that changes are the side effect.
   
   or could we accept the root-level limits is equal with partition-level 
limits? that may be a good way, as the caller can call either root-level limits 
or partition-level limits.



##########
pkg/common/configs/configvalidator.go:
##########
@@ -595,6 +595,28 @@ func checkLimits(limits []Limit, obj string, queue 
*QueueConfig) error {
        return nil
 }
 
+func checkLimitsStructure(partitionConfig *PartitionConfig) error {
+       partitionLimits := partitionConfig.Limits
+       rootQueue := partitionConfig.Queues[0]
+
+       if len(partitionConfig.Queues) < 1 || 
strings.ToLower(partitionConfig.Queues[0].Name) != RootQueue {
+               return fmt.Errorf("top queue is not root")
+       }
+
+       if len(partitionLimits) > 0 && len(rootQueue.Limits) > 0 {
+               return fmt.Errorf("partition limits and root queue limits both 
exist")
+       }
+
+       // if root queue limits not defined, apply partition limits
+       if len(partitionLimits) > 0 && len(rootQueue.Limits) == 0 {
+               partitionConfig.Queues[0].Limits = partitionLimits
+               // clear partition limits
+               partitionConfig.Limits = nil

Review Comment:
   Could you add comment to 
https://github.com/apache/yunikorn-core/blob/master/pkg/common/configs/config.go#L52
 to reminder readers that the field could be empty. Also, we should honor the 
root-level limits.



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