From 11d6576f83a260e32f26a4e70602a054c00c797c Mon Sep 17 00:00:00 2001 From: Jan Chaloupka Date: Sun, 25 Apr 2021 23:27:42 +0200 Subject: [PATCH] noderesource: node info already knows which resources are scalar NodeInfo.Allocatable.ScalarResources already knows which resources are scaler. Also, if the resource name is not present, it's pointless to compute score for a resources the node can not allocate since nodeInfo.Allocatable.ScalarResources[resource] is zero for the case. And both leastRequestedScore and mostRequestedScore returns 0 score for nodes with zero allocatable resource. The balancedResourceScorer deals only with CPU and memory which are not scalable resources. --- .../framework/plugins/noderesources/resource_allocation.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/scheduler/framework/plugins/noderesources/resource_allocation.go b/pkg/scheduler/framework/plugins/noderesources/resource_allocation.go index 8326e5a90a0..33e36abd645 100644 --- a/pkg/scheduler/framework/plugins/noderesources/resource_allocation.go +++ b/pkg/scheduler/framework/plugins/noderesources/resource_allocation.go @@ -99,7 +99,7 @@ func calculateResourceAllocatableRequest(nodeInfo *framework.NodeInfo, pod *v1.P case v1.ResourceEphemeralStorage: return nodeInfo.Allocatable.EphemeralStorage, (nodeInfo.Requested.EphemeralStorage + podRequest) default: - if schedutil.IsScalarResourceName(resource) { + if _, exists := nodeInfo.Allocatable.ScalarResources[resource]; exists { return nodeInfo.Allocatable.ScalarResources[resource], (nodeInfo.Requested.ScalarResources[resource] + podRequest) } }