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 24, 2023
1 parent 6f5b20e commit 467cde3
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 @@ -23,6 +23,7 @@ import (

v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/klog/v2"
v1helper "k8s.io/kubernetes/pkg/scheduler/util"

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

Please sign in to comment.