From cd65afdf05903fd0729c58285af05d92a3cc48b7 Mon Sep 17 00:00:00 2001 From: xiechengsheng Date: Wed, 6 Jun 2018 13:11:26 +0800 Subject: [PATCH] fix some typos Signed-off-by: xiechengsheng --- .../priorities/balanced_resource_allocation.go | 12 ++++++------ pkg/scheduler/algorithm/priorities/image_locality.go | 2 +- .../algorithm/priorities/least_requested.go | 2 +- pkg/scheduler/algorithm/priorities/most_requested.go | 4 ++-- .../algorithm/priorities/resource_limits.go | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/scheduler/algorithm/priorities/balanced_resource_allocation.go b/pkg/scheduler/algorithm/priorities/balanced_resource_allocation.go index ec36f1bf75..85971d316a 100644 --- a/pkg/scheduler/algorithm/priorities/balanced_resource_allocation.go +++ b/pkg/scheduler/algorithm/priorities/balanced_resource_allocation.go @@ -32,7 +32,7 @@ var ( // BalancedResourceAllocationMap should **NOT** be used alone, and **MUST** be used together // with LeastRequestedPriority. It calculates the difference between the cpu and memory fraction // of capacity, and prioritizes the host based on how close the two metrics are to each other. - // Detail: score = 10 - abs(cpuFraction-memoryFraction)*10. The algorithm is partly inspired by: + // Detail: score = 10 - variance(cpuFraction,memoryFraction,volumeFraction)*10. The algorithm is partly inspired by: // "Wei Huang et al. An Energy Efficient Virtual Machine Placement Algorithm with Balanced // Resource Utilization" BalancedResourceAllocationMap = balancedResourcePriority.PriorityMap @@ -44,8 +44,8 @@ func balancedResourceScorer(requested, allocable *schedulercache.Resource, inclu // This to find a node which has most balanced CPU, memory and volume usage. if includeVolumes && utilfeature.DefaultFeatureGate.Enabled(features.BalanceAttachedNodeVolumes) && allocatableVolumes > 0 { volumeFraction := float64(requestedVolumes) / float64(allocatableVolumes) - if cpuFraction >= 1 || memoryFraction >= 1 || volumeFraction >= 1 { - // if requested >= capacity, the corresponding host should never be preferred. + if cpuFraction > 1 || memoryFraction > 1 || volumeFraction > 1 { + // if requested > capacity, the corresponding host should never be preferred. return 0 } // Compute variance for all the three fractions. @@ -57,8 +57,8 @@ func balancedResourceScorer(requested, allocable *schedulercache.Resource, inclu return int64((1 - variance) * float64(schedulerapi.MaxPriority)) } - if cpuFraction >= 1 || memoryFraction >= 1 { - // if requested >= capacity, the corresponding host should never be preferred. + if cpuFraction > 1 || memoryFraction > 1 { + // if requested > capacity, the corresponding host should never be preferred. return 0 } // Upper and lower boundary of difference between cpuFraction and memoryFraction are -1 and 1 @@ -71,7 +71,7 @@ func balancedResourceScorer(requested, allocable *schedulercache.Resource, inclu func fractionOfCapacity(requested, capacity int64) float64 { if capacity == 0 { - return 1 + return math.MaxFloat64 } return float64(requested) / float64(capacity) } diff --git a/pkg/scheduler/algorithm/priorities/image_locality.go b/pkg/scheduler/algorithm/priorities/image_locality.go index 2d399469d6..00820f2b4e 100644 --- a/pkg/scheduler/algorithm/priorities/image_locality.go +++ b/pkg/scheduler/algorithm/priorities/image_locality.go @@ -59,7 +59,7 @@ func calculateScoreFromSize(sumSize int64) int { switch { case sumSize == 0 || sumSize < minImgSize: // 0 means none of the images required by this pod are present on this - // node or the total size of the images present is too small to be taken into further consideration. + // node or the total size of the images present are too small to be taken into further consideration. return 0 case sumSize >= maxImgSize: diff --git a/pkg/scheduler/algorithm/priorities/least_requested.go b/pkg/scheduler/algorithm/priorities/least_requested.go index 9f8b78dae6..d691810896 100644 --- a/pkg/scheduler/algorithm/priorities/least_requested.go +++ b/pkg/scheduler/algorithm/priorities/least_requested.go @@ -29,7 +29,7 @@ var ( // prioritizes based on the minimum of the average of the fraction of requested to capacity. // // Details: - // cpu((capacity-sum(requested))*10/capacity) + memory((capacity-sum(requested))*10/capacity)/2 + // (cpu((capacity-sum(requested))*10/capacity) + memory((capacity-sum(requested))*10/capacity))/2 LeastRequestedPriorityMap = leastResourcePriority.PriorityMap ) diff --git a/pkg/scheduler/algorithm/priorities/most_requested.go b/pkg/scheduler/algorithm/priorities/most_requested.go index ea12e8ef89..f1cc7c6ad5 100644 --- a/pkg/scheduler/algorithm/priorities/most_requested.go +++ b/pkg/scheduler/algorithm/priorities/most_requested.go @@ -39,10 +39,10 @@ func mostResourceScorer(requested, allocable *schedulercache.Resource, includeVo // The used capacity is calculated on a scale of 0-10 // 0 being the lowest priority and 10 being the highest. // The more resources are used the higher the score is. This function -// is almost a reversed version of least_requested_priority.calculatUnusedScore +// is almost a reversed version of least_requested_priority.calculateUnusedScore // (10 - calculateUnusedScore). The main difference is in rounding. It was added to // keep the final formula clean and not to modify the widely used (by users -// in their default scheduling policies) calculateUSedScore. +// in their default scheduling policies) calculateUsedScore. func mostRequestedScore(requested, capacity int64) int64 { if capacity == 0 { return 0 diff --git a/pkg/scheduler/algorithm/priorities/resource_limits.go b/pkg/scheduler/algorithm/priorities/resource_limits.go index 165ac3e3e4..816b423f58 100644 --- a/pkg/scheduler/algorithm/priorities/resource_limits.go +++ b/pkg/scheduler/algorithm/priorities/resource_limits.go @@ -70,7 +70,7 @@ func ResourceLimitsPriorityMap(pod *v1.Pod, meta interface{}, nodeInfo *schedule }, nil } -// computeScore return 1 if limit value is less than or equal to allocable +// computeScore returns 1 if limit value is less than or equal to allocatable // value, otherwise it returns 0. func computeScore(limit, allocatable int64) int64 { if limit != 0 && allocatable != 0 && limit <= allocatable {