@@ -137,7 +137,7 @@ type ScheduleAlgorithm interface {
137
137
// the pod by preempting lower priority pods if possible.
138
138
// It returns the node where preemption happened, a list of preempted pods, a
139
139
// list of pods whose nominated node name should be removed, and error if any.
140
- Preempt (* v1.Pod , error ) (selectedNode * v1.Node , preemptedPods []* v1.Pod , cleanupNominatedPods []* v1.Pod , err error )
140
+ Preempt (* framework. PluginContext , * v1.Pod , error ) (selectedNode * v1.Node , preemptedPods []* v1.Pod , cleanupNominatedPods []* v1.Pod , err error )
141
141
// Predicates() returns a pointer to a map of predicate functions. This is
142
142
// exposed for testing.
143
143
Predicates () map [string ]predicates.FitPredicate
@@ -317,7 +317,7 @@ func (g *genericScheduler) selectHost(priorityList schedulerapi.HostPriorityList
317
317
// other pods with the same priority. The nominated pod prevents other pods from
318
318
// using the nominated resources and the nominated pod could take a long time
319
319
// before it is retried after many other pending pods.
320
- func (g * genericScheduler ) Preempt (pod * v1.Pod , scheduleErr error ) (* v1.Node , []* v1.Pod , []* v1.Pod , error ) {
320
+ func (g * genericScheduler ) Preempt (pluginContext * framework. PluginContext , pod * v1.Pod , scheduleErr error ) (* v1.Node , []* v1.Pod , []* v1.Pod , error ) {
321
321
// Scheduler may return various types of errors. Consider preemption only if
322
322
// the error is of type FitError.
323
323
fitError , ok := scheduleErr .(* FitError )
@@ -342,7 +342,7 @@ func (g *genericScheduler) Preempt(pod *v1.Pod, scheduleErr error) (*v1.Node, []
342
342
if err != nil {
343
343
return nil , nil , nil , err
344
344
}
345
- nodeToVictims , err := selectNodesForPreemption (pod , g .nodeInfoSnapshot .NodeInfoMap , potentialNodes , g .predicates ,
345
+ nodeToVictims , err := g . selectNodesForPreemption (pluginContext , pod , g .nodeInfoSnapshot .NodeInfoMap , potentialNodes , g .predicates ,
346
346
g .predicateMetaProducer , g .schedulingQueue , pdbs )
347
347
if err != nil {
348
348
return nil , nil , nil , err
@@ -489,7 +489,8 @@ func (g *genericScheduler) findNodesThatFit(pluginContext *framework.PluginConte
489
489
checkNode := func (i int ) {
490
490
nodeName := g .cache .NodeTree ().Next ()
491
491
492
- fits , failedPredicates , err := podFitsOnNode (
492
+ fits , failedPredicates , status , err := g .podFitsOnNode (
493
+ pluginContext ,
493
494
pod ,
494
495
meta ,
495
496
g .nodeInfoSnapshot .NodeInfoMap [nodeName ],
@@ -504,18 +505,6 @@ func (g *genericScheduler) findNodesThatFit(pluginContext *framework.PluginConte
504
505
return
505
506
}
506
507
if fits {
507
- // Iterate each plugin to verify current node
508
- status := g .framework .RunFilterPlugins (pluginContext , pod , nodeName )
509
- if ! status .IsSuccess () {
510
- predicateResultLock .Lock ()
511
- filteredNodesStatuses [nodeName ] = status
512
- if ! status .IsUnschedulable () {
513
- errs [status .Message ()]++
514
- }
515
- predicateResultLock .Unlock ()
516
- return
517
- }
518
-
519
508
length := atomic .AddInt32 (& filteredLen , 1 )
520
509
if length > numNodesToFind {
521
510
cancel ()
@@ -525,7 +514,12 @@ func (g *genericScheduler) findNodesThatFit(pluginContext *framework.PluginConte
525
514
}
526
515
} else {
527
516
predicateResultLock .Lock ()
528
- failedPredicateMap [nodeName ] = failedPredicates
517
+ if ! status .IsSuccess () {
518
+ filteredNodesStatuses [nodeName ] = status
519
+ }
520
+ if len (failedPredicates ) != 0 {
521
+ failedPredicateMap [nodeName ] = failedPredicates
522
+ }
529
523
predicateResultLock .Unlock ()
530
524
}
531
525
}
@@ -613,15 +607,17 @@ func addNominatedPods(pod *v1.Pod, meta predicates.PredicateMetadata,
613
607
// When it is called from Preempt, we should remove the victims of preemption and
614
608
// add the nominated pods. Removal of the victims is done by SelectVictimsOnNode().
615
609
// It removes victims from meta and NodeInfo before calling this function.
616
- func podFitsOnNode (
610
+ func (g * genericScheduler ) podFitsOnNode (
611
+ pluginContext * framework.PluginContext ,
617
612
pod * v1.Pod ,
618
613
meta predicates.PredicateMetadata ,
619
614
info * schedulernodeinfo.NodeInfo ,
620
615
predicateFuncs map [string ]predicates.FitPredicate ,
621
616
queue internalqueue.SchedulingQueue ,
622
617
alwaysCheckAllPredicates bool ,
623
- ) (bool , []predicates.PredicateFailureReason , error ) {
618
+ ) (bool , []predicates.PredicateFailureReason , * framework. Status , error ) {
624
619
var failedPredicates []predicates.PredicateFailureReason
620
+ var status * framework.Status
625
621
626
622
podsAdded := false
627
623
// We run predicates twice in some cases. If the node has greater or equal priority
@@ -660,7 +656,7 @@ func podFitsOnNode(
660
656
if predicate , exist := predicateFuncs [predicateKey ]; exist {
661
657
fit , reasons , err = predicate (pod , metaToUse , nodeInfoToUse )
662
658
if err != nil {
663
- return false , []predicates.PredicateFailureReason {}, err
659
+ return false , []predicates.PredicateFailureReason {}, nil , err
664
660
}
665
661
666
662
if ! fit {
@@ -676,9 +672,14 @@ func podFitsOnNode(
676
672
}
677
673
}
678
674
}
675
+
676
+ status = g .framework .RunFilterPlugins (pluginContext , pod , info .Node ().Name )
677
+ if ! status .IsSuccess () && ! status .IsUnschedulable () {
678
+ return false , failedPredicates , status , status .AsError ()
679
+ }
679
680
}
680
681
681
- return len (failedPredicates ) == 0 , failedPredicates , nil
682
+ return len (failedPredicates ) == 0 && status . IsSuccess () , failedPredicates , status , nil
682
683
}
683
684
684
685
// PrioritizeNodes prioritizes the nodes by running the individual priority functions in parallel.
@@ -992,7 +993,9 @@ func pickOneNodeForPreemption(nodesToVictims map[*v1.Node]*schedulerapi.Victims)
992
993
993
994
// selectNodesForPreemption finds all the nodes with possible victims for
994
995
// preemption in parallel.
995
- func selectNodesForPreemption (pod * v1.Pod ,
996
+ func (g * genericScheduler ) selectNodesForPreemption (
997
+ pluginContext * framework.PluginContext ,
998
+ pod * v1.Pod ,
996
999
nodeNameToInfo map [string ]* schedulernodeinfo.NodeInfo ,
997
1000
potentialNodes []* v1.Node ,
998
1001
fitPredicates map [string ]predicates.FitPredicate ,
@@ -1011,7 +1014,7 @@ func selectNodesForPreemption(pod *v1.Pod,
1011
1014
if meta != nil {
1012
1015
metaCopy = meta .ShallowCopy ()
1013
1016
}
1014
- pods , numPDBViolations , fits := selectVictimsOnNode (pod , metaCopy , nodeNameToInfo [nodeName ], fitPredicates , queue , pdbs )
1017
+ pods , numPDBViolations , fits := g . selectVictimsOnNode (pluginContext , pod , metaCopy , nodeNameToInfo [nodeName ], fitPredicates , queue , pdbs )
1015
1018
if fits {
1016
1019
resultLock .Lock ()
1017
1020
victims := schedulerapi.Victims {
@@ -1080,7 +1083,8 @@ func filterPodsWithPDBViolation(pods []interface{}, pdbs []*policy.PodDisruption
1080
1083
// NOTE: This function assumes that it is never called if "pod" cannot be scheduled
1081
1084
// due to pod affinity, node affinity, or node anti-affinity reasons. None of
1082
1085
// these predicates can be satisfied by removing more pods from the node.
1083
- func selectVictimsOnNode (
1086
+ func (g * genericScheduler ) selectVictimsOnNode (
1087
+ pluginContext * framework.PluginContext ,
1084
1088
pod * v1.Pod ,
1085
1089
meta predicates.PredicateMetadata ,
1086
1090
nodeInfo * schedulernodeinfo.NodeInfo ,
@@ -1121,10 +1125,11 @@ func selectVictimsOnNode(
1121
1125
// inter-pod affinity to one or more victims, but we have decided not to
1122
1126
// support this case for performance reasons. Having affinity to lower
1123
1127
// priority pods is not a recommended configuration anyway.
1124
- if fits , _ , err := podFitsOnNode (pod , meta , nodeInfoCopy , fitPredicates , queue , false ); ! fits {
1128
+ if fits , _ , _ , err := g . podFitsOnNode (pluginContext , pod , meta , nodeInfoCopy , fitPredicates , queue , false ); ! fits {
1125
1129
if err != nil {
1126
1130
klog .Warningf ("Encountered error while selecting victims on node %v: %v" , nodeInfo .Node ().Name , err )
1127
1131
}
1132
+
1128
1133
return nil , 0 , false
1129
1134
}
1130
1135
var victims []* v1.Pod
@@ -1136,7 +1141,7 @@ func selectVictimsOnNode(
1136
1141
violatingVictims , nonViolatingVictims := filterPodsWithPDBViolation (potentialVictims .Items , pdbs )
1137
1142
reprievePod := func (p * v1.Pod ) bool {
1138
1143
addPod (p )
1139
- fits , _ , _ := podFitsOnNode (pod , meta , nodeInfoCopy , fitPredicates , queue , false )
1144
+ fits , _ , _ , _ := g . podFitsOnNode (pluginContext , pod , meta , nodeInfoCopy , fitPredicates , queue , false )
1140
1145
if ! fits {
1141
1146
removePod (p )
1142
1147
victims = append (victims , p )
0 commit comments