Skip to content

Commit

Permalink
skip 'pods' resource when checking if the Resource is empty
Browse files Browse the repository at this point in the history
Signed-off-by: lili <lili_9309@163.com>
  • Loading branch information
Lily922 committed Nov 23, 2023
1 parent 6f5b20e commit ee61ba1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pkg/scheduler/api/resource_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package api

import (
"fmt"
"k8s.io/apimachinery/pkg/util/sets"
"math"
"strings"

Expand Down Expand Up @@ -193,13 +194,24 @@ func (r *Resource) Get(rn v1.ResourceName) float64 {
}
}

// Skip checking "pods" resource.
// All pods request one "pods" resource now, no need to check it
var emptyCheckIgnoredScalarResources = sets.NewString("pods")

func IsEmptyCheckIgnoredScalarResource(name v1.ResourceName) bool {
return emptyCheckIgnoredScalarResources.Has(string(name))
}

// IsEmpty returns false if any kind of resource is not less than min value, otherwise returns true
func (r *Resource) IsEmpty() bool {
if !(r.MilliCPU < minResource && r.Memory < minResource) {
return false
}

for _, rQuant := range r.ScalarResources {
for rName, rQuant := range r.ScalarResources {
if IsEmptyCheckIgnoredScalarResource(rName) {
continue
}
if rQuant >= minResource {
return false
}
Expand Down

0 comments on commit ee61ba1

Please sign in to comment.