mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 02:34:03 +00:00
Avoid copying PriorityConfig struct while running priority functions
This commit is contained in:
parent
7af52384ea
commit
70f923ed05
@ -673,8 +673,8 @@ func PrioritizeNodes(
|
|||||||
|
|
||||||
workqueue.ParallelizeUntil(context.TODO(), 16, len(nodes), func(index int) {
|
workqueue.ParallelizeUntil(context.TODO(), 16, len(nodes), func(index int) {
|
||||||
nodeInfo := nodeNameToInfo[nodes[index].Name]
|
nodeInfo := nodeNameToInfo[nodes[index].Name]
|
||||||
for i, priorityConfig := range priorityConfigs {
|
for i := range priorityConfigs {
|
||||||
if priorityConfig.Function != nil {
|
if priorityConfigs[i].Function != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -687,22 +687,22 @@ func PrioritizeNodes(
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
for i, priorityConfig := range priorityConfigs {
|
for i := range priorityConfigs {
|
||||||
if priorityConfig.Reduce == nil {
|
if priorityConfigs[i].Reduce == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func(index int, config algorithm.PriorityConfig) {
|
go func(index int) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
if err := config.Reduce(pod, meta, nodeNameToInfo, results[index]); err != nil {
|
if err := priorityConfigs[i].Reduce(pod, meta, nodeNameToInfo, results[index]); err != nil {
|
||||||
appendError(err)
|
appendError(err)
|
||||||
}
|
}
|
||||||
if klog.V(10) {
|
if klog.V(10) {
|
||||||
for _, hostPriority := range results[index] {
|
for _, hostPriority := range results[index] {
|
||||||
klog.Infof("%v -> %v: %v, Score: (%d)", util.GetPodFullName(pod), hostPriority.Host, config.Name, hostPriority.Score)
|
klog.Infof("%v -> %v: %v, Score: (%d)", util.GetPodFullName(pod), hostPriority.Host, priorityConfigs[i].Name, hostPriority.Score)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}(i, priorityConfig)
|
}(i)
|
||||||
}
|
}
|
||||||
// Wait for all computations to be finished.
|
// Wait for all computations to be finished.
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
Loading…
Reference in New Issue
Block a user