Skip to content

Commit 894916b

Browse files
authored
Merge pull request kubernetes#89459 from chendave/scorer_desc
Trival fix: update the desc on the score plugins
2 parents 1442df8 + 4ab7be4 commit 894916b

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

pkg/scheduler/framework/plugins/noderesources/balanced_allocation.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (ba *BalancedAllocation) Score(ctx context.Context, state *framework.CycleS
5656
// It should **NOT** be used alone, and **MUST** be used together
5757
// with NodeResourcesLeastAllocated plugin. It calculates the difference between the cpu and memory fraction
5858
// of capacity, and prioritizes the host based on how close the two metrics are to each other.
59-
// Detail: score = 10 - variance(cpuFraction,memoryFraction,volumeFraction)*10. The algorithm is partly inspired by:
59+
// Detail: score = (1 - variance(cpuFraction,memoryFraction,volumeFraction)) * MaxNodeScore. The algorithm is partly inspired by:
6060
// "Wei Huang et al. An Energy Efficient Virtual Machine Placement Algorithm with Balanced
6161
// Resource Utilization"
6262
return ba.score(pod, nodeInfo)
@@ -99,15 +99,15 @@ func balancedResourceScorer(requested, allocable resourceToValueMap, includeVolu
9999
mean := (cpuFraction + memoryFraction + volumeFraction) / float64(3)
100100
variance := float64((((cpuFraction - mean) * (cpuFraction - mean)) + ((memoryFraction - mean) * (memoryFraction - mean)) + ((volumeFraction - mean) * (volumeFraction - mean))) / float64(3))
101101
// Since the variance is between positive fractions, it will be positive fraction. 1-variance lets the
102-
// score to be higher for node which has least variance and multiplying it with 10 provides the scaling
102+
// score to be higher for node which has least variance and multiplying it with `MaxNodeScore` provides the scaling
103103
// factor needed.
104104
return int64((1 - variance) * float64(framework.MaxNodeScore))
105105
}
106106

107107
// Upper and lower boundary of difference between cpuFraction and memoryFraction are -1 and 1
108-
// respectively. Multiplying the absolute value of the difference by 10 scales the value to
109-
// 0-10 with 0 representing well balanced allocation and 10 poorly balanced. Subtracting it from
110-
// 10 leads to the score which also scales from 0 to 10 while 10 representing well balanced.
108+
// respectively. Multiplying the absolute value of the difference by `MaxNodeScore` scales the value to
109+
// 0-MaxNodeScore with 0 representing well balanced allocation and `MaxNodeScore` poorly balanced. Subtracting it from
110+
// `MaxNodeScore` leads to the score which also scales from 0 to `MaxNodeScore` while `MaxNodeScore` representing well balanced.
111111
diff := math.Abs(cpuFraction - memoryFraction)
112112
return int64((1 - diff) * float64(framework.MaxNodeScore))
113113
}

pkg/scheduler/framework/plugins/noderesources/least_allocated.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (la *LeastAllocated) Score(ctx context.Context, state *framework.CycleState
5353
// prioritizes based on the minimum of the average of the fraction of requested to capacity.
5454
//
5555
// Details:
56-
// (cpu((capacity-sum(requested))*10/capacity) + memory((capacity-sum(requested))*10/capacity))/2
56+
// (cpu((capacity-sum(requested))*MaxNodeScore/capacity) + memory((capacity-sum(requested))*MaxNodeScore/capacity))/weightSum
5757
return la.score(pod, nodeInfo)
5858
}
5959

@@ -84,8 +84,8 @@ func leastResourceScorer(requested, allocable resourceToValueMap, includeVolumes
8484
return nodeScore / weightSum
8585
}
8686

87-
// The unused capacity is calculated on a scale of 0-10
88-
// 0 being the lowest priority and 10 being the highest.
87+
// The unused capacity is calculated on a scale of 0-MaxNodeScore
88+
// 0 being the lowest priority and `MaxNodeScore` being the highest.
8989
// The more unused resources the higher the score is.
9090
func leastRequestedScore(requested, capacity int64) int64 {
9191
if capacity == 0 {

0 commit comments

Comments
 (0)