in pkg/common/configs/configvalidator.go [143:212]
func checkLimitResource(cur QueueConfig, users map[string]map[string]*resources.Resource, groups map[string]map[string]*resources.Resource, queuePath string) error {
var curQueuePath string
if cur.Name == RootQueue {
curQueuePath = RootQueue
} else {
curQueuePath = queuePath + DOT + cur.Name
}
users[curQueuePath] = make(map[string]*resources.Resource)
groups[curQueuePath] = make(map[string]*resources.Resource)
// Carry forward (populate) the parent limit settings to the next level
for u, v := range users[queuePath] {
users[curQueuePath][u] = v.Clone()
}
for g, v := range groups[queuePath] {
groups[curQueuePath][g] = v.Clone()
}
// compare user & group limit setting between the current queue and parent queue
for _, limit := range cur.Limits {
limitMaxResources, err := resources.NewResourceFromConf(limit.MaxResources)
if err != nil {
return err
}
for _, user := range limit.Users {
// Is user limit setting exists?
if userMaxResource, ok := users[queuePath][user]; ok {
if !userMaxResource.FitInMaxUndef(limitMaxResources) {
return fmt.Errorf("user %s max resource %s of queue %s is greater than immediate or ancestor parent maximum resource %s", user, limitMaxResources.String(), cur.Name, userMaxResource.String())
}
users[curQueuePath][user] = resources.ComponentWiseMin(limitMaxResources, userMaxResource)
} else if wildcardMaxResource, ok := users[queuePath][common.Wildcard]; user != common.Wildcard && ok {
if !wildcardMaxResource.FitInMaxUndef(limitMaxResources) {
return fmt.Errorf("user %s max resource %s of queue %s is greater than wildcard maximum resource %s of immediate or ancestor parent queue", user, limitMaxResources.String(), cur.Name, wildcardMaxResource.String())
}
users[curQueuePath][user] = limitMaxResources
} else {
users[curQueuePath][user] = limitMaxResources
}
}
for _, group := range limit.Groups {
// Is group limit setting exists?
if groupMaxResource, ok := groups[queuePath][group]; ok {
if !groupMaxResource.FitInMaxUndef(limitMaxResources) {
return fmt.Errorf("group %s max resource %s of queue %s is greater than immediate or ancestor parent maximum resource %s", group, limitMaxResources.String(), cur.Name, groupMaxResource.String())
}
// Override with min resource
groups[curQueuePath][group] = resources.ComponentWiseMin(limitMaxResources, groupMaxResource)
} else if wildcardMaxResource, ok := groups[queuePath][common.Wildcard]; group != common.Wildcard && ok {
if !wildcardMaxResource.FitInMaxUndef(limitMaxResources) {
return fmt.Errorf("group %s max resource %s of queue %s is greater than wildcard maximum resource %s of immediate or ancestor parent queue", group, limitMaxResources.String(), cur.Name, wildcardMaxResource.String())
}
groups[curQueuePath][group] = limitMaxResources
} else {
groups[curQueuePath][group] = limitMaxResources
}
}
}
// traverse child queues
for _, child := range cur.Queues {
err := checkLimitResource(child, users, groups, curQueuePath)
if err != nil {
return err
}
}
return nil
}