@@ -134,12 +134,12 @@ func (f *FitError) Error() string {
134
134
// onto machines.
135
135
// TODO: Rename this type.
136
136
type ScheduleAlgorithm interface {
137
- Schedule (* framework.PluginContext , * v1.Pod ) (scheduleResult ScheduleResult , err error )
137
+ Schedule (* framework.CycleState , * v1.Pod ) (scheduleResult ScheduleResult , err error )
138
138
// Preempt receives scheduling errors for a pod and tries to create room for
139
139
// the pod by preempting lower priority pods if possible.
140
140
// It returns the node where preemption happened, a list of preempted pods, a
141
141
// list of pods whose nominated node name should be removed, and error if any.
142
- Preempt (* framework.PluginContext , * v1.Pod , error ) (selectedNode * v1.Node , preemptedPods []* v1.Pod , cleanupNominatedPods []* v1.Pod , err error )
142
+ Preempt (* framework.CycleState , * v1.Pod , error ) (selectedNode * v1.Node , preemptedPods []* v1.Pod , cleanupNominatedPods []* v1.Pod , err error )
143
143
// Predicates() returns a pointer to a map of predicate functions. This is
144
144
// exposed for testing.
145
145
Predicates () map [string ]predicates.FitPredicate
@@ -191,7 +191,7 @@ func (g *genericScheduler) snapshot() error {
191
191
// Schedule tries to schedule the given pod to one of the nodes in the node list.
192
192
// If it succeeds, it will return the name of the node.
193
193
// If it fails, it will return a FitError error with reasons.
194
- func (g * genericScheduler ) Schedule (pluginContext * framework.PluginContext , pod * v1.Pod ) (result ScheduleResult , err error ) {
194
+ func (g * genericScheduler ) Schedule (state * framework.CycleState , pod * v1.Pod ) (result ScheduleResult , err error ) {
195
195
trace := utiltrace .New ("Scheduling" , utiltrace.Field {Key : "namespace" , Value : pod .Namespace }, utiltrace.Field {Key : "name" , Value : pod .Name })
196
196
defer trace .LogIfLong (100 * time .Millisecond )
197
197
@@ -200,7 +200,7 @@ func (g *genericScheduler) Schedule(pluginContext *framework.PluginContext, pod
200
200
}
201
201
202
202
// Run "prefilter" plugins.
203
- preFilterStatus := g .framework .RunPreFilterPlugins (pluginContext , pod )
203
+ preFilterStatus := g .framework .RunPreFilterPlugins (state , pod )
204
204
if ! preFilterStatus .IsSuccess () {
205
205
return result , preFilterStatus .AsError ()
206
206
}
@@ -216,13 +216,13 @@ func (g *genericScheduler) Schedule(pluginContext *framework.PluginContext, pod
216
216
217
217
trace .Step ("Basic checks done" )
218
218
startPredicateEvalTime := time .Now ()
219
- filteredNodes , failedPredicateMap , filteredNodesStatuses , err := g .findNodesThatFit (pluginContext , pod )
219
+ filteredNodes , failedPredicateMap , filteredNodesStatuses , err := g .findNodesThatFit (state , pod )
220
220
if err != nil {
221
221
return result , err
222
222
}
223
223
224
224
// Run "postfilter" plugins.
225
- postfilterStatus := g .framework .RunPostFilterPlugins (pluginContext , pod , filteredNodes , filteredNodesStatuses )
225
+ postfilterStatus := g .framework .RunPostFilterPlugins (state , pod , filteredNodes , filteredNodesStatuses )
226
226
if ! postfilterStatus .IsSuccess () {
227
227
return result , postfilterStatus .AsError ()
228
228
}
@@ -254,7 +254,7 @@ func (g *genericScheduler) Schedule(pluginContext *framework.PluginContext, pod
254
254
}
255
255
256
256
metaPrioritiesInterface := g .priorityMetaProducer (pod , g .nodeInfoSnapshot .NodeInfoMap )
257
- priorityList , err := PrioritizeNodes (pod , g .nodeInfoSnapshot .NodeInfoMap , metaPrioritiesInterface , g .prioritizers , filteredNodes , g .extenders , g .framework , pluginContext )
257
+ priorityList , err := PrioritizeNodes (pod , g .nodeInfoSnapshot .NodeInfoMap , metaPrioritiesInterface , g .prioritizers , filteredNodes , g .extenders , g .framework , state )
258
258
if err != nil {
259
259
return result , err
260
260
}
@@ -326,7 +326,7 @@ func (g *genericScheduler) selectHost(nodeScoreList framework.NodeScoreList) (st
326
326
// other pods with the same priority. The nominated pod prevents other pods from
327
327
// using the nominated resources and the nominated pod could take a long time
328
328
// before it is retried after many other pending pods.
329
- func (g * genericScheduler ) Preempt (pluginContext * framework.PluginContext , pod * v1.Pod , scheduleErr error ) (* v1.Node , []* v1.Pod , []* v1.Pod , error ) {
329
+ func (g * genericScheduler ) Preempt (state * framework.CycleState , pod * v1.Pod , scheduleErr error ) (* v1.Node , []* v1.Pod , []* v1.Pod , error ) {
330
330
// Scheduler may return various types of errors. Consider preemption only if
331
331
// the error is of type FitError.
332
332
fitError , ok := scheduleErr .(* FitError )
@@ -351,7 +351,7 @@ func (g *genericScheduler) Preempt(pluginContext *framework.PluginContext, pod *
351
351
if err != nil {
352
352
return nil , nil , nil , err
353
353
}
354
- nodeToVictims , err := g .selectNodesForPreemption (pluginContext , pod , g .nodeInfoSnapshot .NodeInfoMap , potentialNodes , g .predicates ,
354
+ nodeToVictims , err := g .selectNodesForPreemption (state , pod , g .nodeInfoSnapshot .NodeInfoMap , potentialNodes , g .predicates ,
355
355
g .predicateMetaProducer , g .schedulingQueue , pdbs )
356
356
if err != nil {
357
357
return nil , nil , nil , err
@@ -470,7 +470,7 @@ func (g *genericScheduler) numFeasibleNodesToFind(numAllNodes int32) (numNodes i
470
470
471
471
// Filters the nodes to find the ones that fit based on the given predicate functions
472
472
// Each node is passed through the predicate functions to determine if it is a fit
473
- func (g * genericScheduler ) findNodesThatFit (pluginContext * framework.PluginContext , pod * v1.Pod ) ([]* v1.Node , FailedPredicateMap , framework.NodeToStatusMap , error ) {
473
+ func (g * genericScheduler ) findNodesThatFit (state * framework.CycleState , pod * v1.Pod ) ([]* v1.Node , FailedPredicateMap , framework.NodeToStatusMap , error ) {
474
474
var filtered []* v1.Node
475
475
failedPredicateMap := FailedPredicateMap {}
476
476
filteredNodesStatuses := framework.NodeToStatusMap {}
@@ -499,7 +499,7 @@ func (g *genericScheduler) findNodesThatFit(pluginContext *framework.PluginConte
499
499
nodeName := g .cache .NodeTree ().Next ()
500
500
501
501
fits , failedPredicates , status , err := g .podFitsOnNode (
502
- pluginContext ,
502
+ state ,
503
503
pod ,
504
504
meta ,
505
505
g .nodeInfoSnapshot .NodeInfoMap [nodeName ],
@@ -619,7 +619,7 @@ func addNominatedPods(pod *v1.Pod, meta predicates.PredicateMetadata,
619
619
// add the nominated pods. Removal of the victims is done by SelectVictimsOnNode().
620
620
// It removes victims from meta and NodeInfo before calling this function.
621
621
func (g * genericScheduler ) podFitsOnNode (
622
- pluginContext * framework.PluginContext ,
622
+ state * framework.CycleState ,
623
623
pod * v1.Pod ,
624
624
meta predicates.PredicateMetadata ,
625
625
info * schedulernodeinfo.NodeInfo ,
@@ -684,7 +684,7 @@ func (g *genericScheduler) podFitsOnNode(
684
684
}
685
685
}
686
686
687
- status = g .framework .RunFilterPlugins (pluginContext , pod , nodeInfoToUse )
687
+ status = g .framework .RunFilterPlugins (state , pod , nodeInfoToUse )
688
688
if ! status .IsSuccess () && ! status .IsUnschedulable () {
689
689
return false , failedPredicates , status , status .AsError ()
690
690
}
@@ -707,7 +707,7 @@ func PrioritizeNodes(
707
707
nodes []* v1.Node ,
708
708
extenders []algorithm.SchedulerExtender ,
709
709
fwk framework.Framework ,
710
- pluginContext * framework.PluginContext ) (framework.NodeScoreList , error ) {
710
+ state * framework.CycleState ) (framework.NodeScoreList , error ) {
711
711
// If no priority configs are provided, then the EqualPriority function is applied
712
712
// This is required to generate the priority list in the required format
713
713
if len (priorityConfigs ) == 0 && len (extenders ) == 0 {
@@ -793,7 +793,7 @@ func PrioritizeNodes(
793
793
}
794
794
795
795
// Run the Score plugins.
796
- scoresMap , scoreStatus := fwk .RunScorePlugins (pluginContext , pod , nodes )
796
+ scoresMap , scoreStatus := fwk .RunScorePlugins (state , pod , nodes )
797
797
if ! scoreStatus .IsSuccess () {
798
798
return framework.NodeScoreList {}, scoreStatus .AsError ()
799
799
}
@@ -1005,7 +1005,7 @@ func pickOneNodeForPreemption(nodesToVictims map[*v1.Node]*extenderv1.Victims) *
1005
1005
// selectNodesForPreemption finds all the nodes with possible victims for
1006
1006
// preemption in parallel.
1007
1007
func (g * genericScheduler ) selectNodesForPreemption (
1008
- pluginContext * framework.PluginContext ,
1008
+ state * framework.CycleState ,
1009
1009
pod * v1.Pod ,
1010
1010
nodeNameToInfo map [string ]* schedulernodeinfo.NodeInfo ,
1011
1011
potentialNodes []* v1.Node ,
@@ -1025,9 +1025,9 @@ func (g *genericScheduler) selectNodesForPreemption(
1025
1025
if meta != nil {
1026
1026
metaCopy = meta .ShallowCopy ()
1027
1027
}
1028
- pluginContextClone := pluginContext .Clone ()
1028
+ stateClone := state .Clone ()
1029
1029
pods , numPDBViolations , fits := g .selectVictimsOnNode (
1030
- pluginContextClone , pod , metaCopy , nodeNameToInfo [nodeName ], fitPredicates , queue , pdbs )
1030
+ stateClone , pod , metaCopy , nodeNameToInfo [nodeName ], fitPredicates , queue , pdbs )
1031
1031
if fits {
1032
1032
resultLock .Lock ()
1033
1033
victims := extenderv1.Victims {
@@ -1097,7 +1097,7 @@ func filterPodsWithPDBViolation(pods []interface{}, pdbs []*policy.PodDisruption
1097
1097
// due to pod affinity, node affinity, or node anti-affinity reasons. None of
1098
1098
// these predicates can be satisfied by removing more pods from the node.
1099
1099
func (g * genericScheduler ) selectVictimsOnNode (
1100
- pluginContext * framework.PluginContext ,
1100
+ state * framework.CycleState ,
1101
1101
pod * v1.Pod ,
1102
1102
meta predicates.PredicateMetadata ,
1103
1103
nodeInfo * schedulernodeinfo.NodeInfo ,
@@ -1120,7 +1120,7 @@ func (g *genericScheduler) selectVictimsOnNode(
1120
1120
return err
1121
1121
}
1122
1122
}
1123
- status := g .framework .RunPreFilterExtensionRemovePod (pluginContext , pod , rp , nodeInfoCopy )
1123
+ status := g .framework .RunPreFilterExtensionRemovePod (state , pod , rp , nodeInfoCopy )
1124
1124
if ! status .IsSuccess () {
1125
1125
return status .AsError ()
1126
1126
}
@@ -1133,7 +1133,7 @@ func (g *genericScheduler) selectVictimsOnNode(
1133
1133
return err
1134
1134
}
1135
1135
}
1136
- status := g .framework .RunPreFilterExtensionAddPod (pluginContext , pod , ap , nodeInfoCopy )
1136
+ status := g .framework .RunPreFilterExtensionAddPod (state , pod , ap , nodeInfoCopy )
1137
1137
if ! status .IsSuccess () {
1138
1138
return status .AsError ()
1139
1139
}
@@ -1156,7 +1156,7 @@ func (g *genericScheduler) selectVictimsOnNode(
1156
1156
// inter-pod affinity to one or more victims, but we have decided not to
1157
1157
// support this case for performance reasons. Having affinity to lower
1158
1158
// priority pods is not a recommended configuration anyway.
1159
- if fits , _ , _ , err := g .podFitsOnNode (pluginContext , pod , meta , nodeInfoCopy , fitPredicates , queue , false ); ! fits {
1159
+ if fits , _ , _ , err := g .podFitsOnNode (state , pod , meta , nodeInfoCopy , fitPredicates , queue , false ); ! fits {
1160
1160
if err != nil {
1161
1161
klog .Warningf ("Encountered error while selecting victims on node %v: %v" , nodeInfo .Node ().Name , err )
1162
1162
}
@@ -1174,7 +1174,7 @@ func (g *genericScheduler) selectVictimsOnNode(
1174
1174
if err := addPod (p ); err != nil {
1175
1175
return false , err
1176
1176
}
1177
- fits , _ , _ , _ := g .podFitsOnNode (pluginContext , pod , meta , nodeInfoCopy , fitPredicates , queue , false )
1177
+ fits , _ , _ , _ := g .podFitsOnNode (state , pod , meta , nodeInfoCopy , fitPredicates , queue , false )
1178
1178
if ! fits {
1179
1179
if err := removePod (p ); err != nil {
1180
1180
return false , err
0 commit comments