diff --git a/pkg/scheduler/plugins/drf/drf.go b/pkg/scheduler/plugins/drf/drf.go index 46ecfb20dc..722f94f12b 100644 --- a/pkg/scheduler/plugins/drf/drf.go +++ b/pkg/scheduler/plugins/drf/drf.go @@ -157,13 +157,7 @@ func (drf *drfPlugin) compareQueues(root *hierarchicalNode, lqueue *api.QueueInf lpaths := strings.Split(lqueue.Hierarchy, "/") rnode := root rpaths := strings.Split(rqueue.Hierarchy, "/") - depth := 0 - if len(lpaths) < len(rpaths) { - depth = len(lpaths) - } else { - depth = len(rpaths) - } - for i := 0; i < depth; i++ { + for i, depth := 0, min(len(lpaths), len(rpaths)); i < depth; i++ { // Saturated nodes have minumun prioirty, // so that demanding nodes will be poped first. if !lnode.saturated && rnode.saturated {