123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package priorities
- import (
- schedulerapi "k8s.io/kubernetes/pkg/scheduler/api"
- schedulernodeinfo "k8s.io/kubernetes/pkg/scheduler/nodeinfo"
- )
- var (
- leastResourcePriority = &ResourceAllocationPriority{"LeastResourceAllocation", leastResourceScorer}
-
-
-
-
-
-
- LeastRequestedPriorityMap = leastResourcePriority.PriorityMap
- )
- func leastResourceScorer(requested, allocable *schedulernodeinfo.Resource, includeVolumes bool, requestedVolumes int, allocatableVolumes int) int64 {
- return (leastRequestedScore(requested.MilliCPU, allocable.MilliCPU) +
- leastRequestedScore(requested.Memory, allocable.Memory)) / 2
- }
- func leastRequestedScore(requested, capacity int64) int64 {
- if capacity == 0 {
- return 0
- }
- if requested > capacity {
- return 0
- }
- return ((capacity - requested) * int64(schedulerapi.MaxPriority)) / capacity
- }
|