Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cherry-pick for release-1.8]skip 'pods' resource when checking if the Resource is empty #3224

Merged
merged 1 commit into from
Nov 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading