Skip to content

Commit

Permalink
Merge pull request #3224 from Lily922/release-1.8
Browse files Browse the repository at this point in the history
[cherry-pick for release-1.8]skip 'pods' resource when checking if the Resource is empty
  • Loading branch information
volcano-sh-bot authored Nov 25, 2023
2 parents 6f5b20e + 99f4d38 commit 5a2b618
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions 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 {
}
}

// IsEmpty returns false if any kind of resource is not less than min value, otherwise returns true
// Skip checking "pods" resource.
// All pods request one "pods" resource now, no need to check it
var ignoredScalarResources = sets.NewString(string(v1.ResourcePods))

func IsIgnoredScalarResource(name v1.ResourceName) bool {
return ignoredScalarResources.Has(string(name))
}

// IsEmpty returns false if any kind of resource other than IgnoredResources 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 IsIgnoredScalarResource(rName) {
continue
}
if rQuant >= minResource {
return false
}
Expand Down

0 comments on commit 5a2b618

Please sign in to comment.