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.
This commit is contained in:
Jan Chaloupka 2021-04-25 23:27:42 +02:00
parent 5c34712a09
commit 11d6576f83

View File

@ -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)
}
}