mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
Avoid growing slices
This commit is contained in:
parent
6c77c01f24
commit
31538db145
@ -85,7 +85,7 @@ func LeastRequestedPriority(pod *api.Pod, nodeNameToInfo map[string]*schedulerca
|
|||||||
return schedulerapi.HostPriorityList{}, err
|
return schedulerapi.HostPriorityList{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
list := schedulerapi.HostPriorityList{}
|
list := make(schedulerapi.HostPriorityList, 0, len(nodes.Items))
|
||||||
for i := range nodes.Items {
|
for i := range nodes.Items {
|
||||||
node := &nodes.Items[i]
|
node := &nodes.Items[i]
|
||||||
list = append(list, calculateResourceOccupancy(pod, node, nodeNameToInfo[node.Name]))
|
list = append(list, calculateResourceOccupancy(pod, node, nodeNameToInfo[node.Name]))
|
||||||
@ -122,7 +122,7 @@ func (n *NodeLabelPrioritizer) CalculateNodeLabelPriority(pod *api.Pod, nodeName
|
|||||||
labeledNodes[node.Name] = (exists && n.presence) || (!exists && !n.presence)
|
labeledNodes[node.Name] = (exists && n.presence) || (!exists && !n.presence)
|
||||||
}
|
}
|
||||||
|
|
||||||
result := []schedulerapi.HostPriority{}
|
result := make(schedulerapi.HostPriorityList, 0, len(nodes.Items))
|
||||||
//score int - scale of 0-10
|
//score int - scale of 0-10
|
||||||
// 0 being the lowest priority and 10 being the highest
|
// 0 being the lowest priority and 10 being the highest
|
||||||
for nodeName, success := range labeledNodes {
|
for nodeName, success := range labeledNodes {
|
||||||
@ -166,7 +166,7 @@ func ImageLocalityPriority(pod *api.Pod, nodeNameToInfo map[string]*schedulercac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result := []schedulerapi.HostPriority{}
|
result := make(schedulerapi.HostPriorityList, 0, len(nodes.Items))
|
||||||
// score int - scale of 0-10
|
// score int - scale of 0-10
|
||||||
// 0 being the lowest priority and 10 being the highest.
|
// 0 being the lowest priority and 10 being the highest.
|
||||||
for nodeName, sumSize := range sumSizeMap {
|
for nodeName, sumSize := range sumSizeMap {
|
||||||
@ -221,7 +221,7 @@ func BalancedResourceAllocation(pod *api.Pod, nodeNameToInfo map[string]*schedul
|
|||||||
return schedulerapi.HostPriorityList{}, err
|
return schedulerapi.HostPriorityList{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
list := schedulerapi.HostPriorityList{}
|
list := make(schedulerapi.HostPriorityList, 0, len(nodes.Items))
|
||||||
for i := range nodes.Items {
|
for i := range nodes.Items {
|
||||||
node := &nodes.Items[i]
|
node := &nodes.Items[i]
|
||||||
list = append(list, calculateBalancedResourceAllocation(pod, node, nodeNameToInfo[node.Name]))
|
list = append(list, calculateBalancedResourceAllocation(pod, node, nodeNameToInfo[node.Name]))
|
||||||
|
@ -207,7 +207,7 @@ func (s *SelectorSpread) CalculateSpreadPriority(pod *api.Pod, nodeNameToInfo ma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result := []schedulerapi.HostPriority{}
|
result := make(schedulerapi.HostPriorityList, 0, len(nodes.Items))
|
||||||
//score int - scale of 0-maxPriority
|
//score int - scale of 0-maxPriority
|
||||||
// 0 being the lowest priority and maxPriority being the highest
|
// 0 being the lowest priority and maxPriority being the highest
|
||||||
for i := range nodes.Items {
|
for i := range nodes.Items {
|
||||||
|
@ -100,7 +100,7 @@ func (s *TaintToleration) ComputeTaintTolerationPriority(pod *api.Pod, nodeNameT
|
|||||||
// The maximum priority value to give to a node
|
// The maximum priority value to give to a node
|
||||||
// Priority values range from 0 - maxPriority
|
// Priority values range from 0 - maxPriority
|
||||||
const maxPriority = 10
|
const maxPriority = 10
|
||||||
result := []schedulerapi.HostPriority{}
|
result := make(schedulerapi.HostPriorityList, 0, len(nodes.Items))
|
||||||
for _, node := range nodes.Items {
|
for _, node := range nodes.Items {
|
||||||
fScore := float64(maxPriority)
|
fScore := float64(maxPriority)
|
||||||
if maxCount > 0 {
|
if maxCount > 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user