mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-11-13 23:15:10 +00:00
Score plugin for the scheduling framework.
This commit is contained in:
@@ -240,7 +240,7 @@ func (g *genericScheduler) Schedule(pod *v1.Pod, nodeLister algorithm.NodeLister
|
||||
}
|
||||
|
||||
metaPrioritiesInterface := g.priorityMetaProducer(pod, g.nodeInfoSnapshot.NodeInfoMap)
|
||||
priorityList, err := PrioritizeNodes(pod, g.nodeInfoSnapshot.NodeInfoMap, metaPrioritiesInterface, g.prioritizers, filteredNodes, g.extenders)
|
||||
priorityList, err := PrioritizeNodes(pod, g.nodeInfoSnapshot.NodeInfoMap, metaPrioritiesInterface, g.prioritizers, filteredNodes, g.extenders, g.framework, pluginContext)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
@@ -677,7 +677,8 @@ func PrioritizeNodes(
|
||||
priorityConfigs []priorities.PriorityConfig,
|
||||
nodes []*v1.Node,
|
||||
extenders []algorithm.SchedulerExtender,
|
||||
) (schedulerapi.HostPriorityList, error) {
|
||||
framework framework.Framework,
|
||||
pluginContext *framework.PluginContext) (schedulerapi.HostPriorityList, error) {
|
||||
// If no priority configs are provided, then the EqualPriority function is applied
|
||||
// This is required to generate the priority list in the required format
|
||||
if len(priorityConfigs) == 0 && len(extenders) == 0 {
|
||||
@@ -762,6 +763,12 @@ func PrioritizeNodes(
|
||||
return schedulerapi.HostPriorityList{}, errors.NewAggregate(errs)
|
||||
}
|
||||
|
||||
// Run the Score plugins.
|
||||
scoresMap, scoreStatus := framework.RunScorePlugins(pluginContext, pod, nodes)
|
||||
if !scoreStatus.IsSuccess() {
|
||||
return schedulerapi.HostPriorityList{}, scoreStatus.AsError()
|
||||
}
|
||||
|
||||
// Summarize all scores.
|
||||
result := make(schedulerapi.HostPriorityList, 0, len(nodes))
|
||||
|
||||
@@ -772,6 +779,12 @@ func PrioritizeNodes(
|
||||
}
|
||||
}
|
||||
|
||||
for _, scoreList := range scoresMap {
|
||||
for i := range nodes {
|
||||
result[i].Score += scoreList[i]
|
||||
}
|
||||
}
|
||||
|
||||
if len(extenders) != 0 && nodes != nil {
|
||||
combinedScores := make(map[string]int, len(nodeNameToInfo))
|
||||
for i := range extenders {
|
||||
|
||||
Reference in New Issue
Block a user