mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-02 19:28:16 +00:00
Fix Node Resources plugins score when there are pods with no requests
Given that we give a default CPU/memory requests for containers that don't provide any, the calculated usage can exceed the allocatable. Change-Id: I72e249652acacfbe8cea0dd6f895dabe43ff6376
This commit is contained in:
@@ -82,12 +82,16 @@ func NewBalancedAllocation(_ runtime.Object, h framework.Handle, fts feature.Fea
|
||||
|
||||
// todo: use resource weights in the scorer function
|
||||
func balancedResourceScorer(requested, allocable resourceToValueMap, includeVolumes bool, requestedVolumes int, allocatableVolumes int) int64 {
|
||||
// This to find a node which has most balanced CPU, memory and volume usage.
|
||||
cpuFraction := fractionOfCapacity(requested[v1.ResourceCPU], allocable[v1.ResourceCPU])
|
||||
memoryFraction := fractionOfCapacity(requested[v1.ResourceMemory], allocable[v1.ResourceMemory])
|
||||
// This to find a node which has most balanced CPU, memory and volume usage.
|
||||
if cpuFraction >= 1 || memoryFraction >= 1 {
|
||||
// if requested >= capacity, the corresponding host should never be preferred.
|
||||
return 0
|
||||
// fractions might be greater than 1 because pods with no requests get minimum
|
||||
// values.
|
||||
if cpuFraction > 1 {
|
||||
cpuFraction = 1
|
||||
}
|
||||
if memoryFraction > 1 {
|
||||
memoryFraction = 1
|
||||
}
|
||||
|
||||
// includeVolumes is only true when BalanceAttachedNodeVolumes feature gate is enabled (see resource_allocation.go#score())
|
||||
|
||||
Reference in New Issue
Block a user