@@ -280,7 +280,7 @@ func (g *genericScheduler) Preempt(ctx context.Context, prof *profile.Profile, s
280
280
return "" , nil , nil , err
281
281
}
282
282
}
283
- nodeNameToVictims , err := g . selectNodesForPreemption (ctx , prof , state , pod , potentialNodes , pdbs )
283
+ nodeNameToVictims , err := selectNodesForPreemption (ctx , prof , g . podNominator , state , pod , potentialNodes , pdbs )
284
284
if err != nil {
285
285
return "" , nil , nil , err
286
286
}
@@ -442,7 +442,7 @@ func (g *genericScheduler) findNodesThatPassFilters(ctx context.Context, prof *p
442
442
// We check the nodes starting from where we left off in the previous scheduling cycle,
443
443
// this is to make sure all nodes have the same chance of being examined across pods.
444
444
nodeInfo := allNodes [(g .nextStartNodeIndex + i )% len (allNodes )]
445
- fits , status , err := g . podPassesFiltersOnNode (ctx , prof , state , pod , nodeInfo )
445
+ fits , status , err := podPassesFiltersOnNode (ctx , prof , g . podNominator , state , pod , nodeInfo )
446
446
if err != nil {
447
447
errCh .SendErrorWithCancel (err , cancel )
448
448
return
@@ -520,12 +520,12 @@ func (g *genericScheduler) findNodesThatPassExtenders(pod *v1.Pod, filtered []*v
520
520
// addNominatedPods adds pods with equal or greater priority which are nominated
521
521
// to run on the node. It returns 1) whether any pod was added, 2) augmented cycleState,
522
522
// 3) augmented nodeInfo.
523
- func ( g * genericScheduler ) addNominatedPods (ctx context.Context , prof * profile. Profile , pod * v1.Pod , state * framework.CycleState , nodeInfo * framework.NodeInfo ) (bool , * framework.CycleState , * framework.NodeInfo , error ) {
524
- if g . podNominator == nil || nodeInfo == nil || nodeInfo .Node () == nil {
523
+ func addNominatedPods (ctx context.Context , pr framework. PluginsRunner , nominator framework. PodNominator , pod * v1.Pod , state * framework.CycleState , nodeInfo * framework.NodeInfo ) (bool , * framework.CycleState , * framework.NodeInfo , error ) {
524
+ if nominator == nil || nodeInfo == nil || nodeInfo .Node () == nil {
525
525
// This may happen only in tests.
526
526
return false , state , nodeInfo , nil
527
527
}
528
- nominatedPods := g . podNominator .NominatedPodsForNode (nodeInfo .Node ().Name )
528
+ nominatedPods := nominator .NominatedPodsForNode (nodeInfo .Node ().Name )
529
529
if len (nominatedPods ) == 0 {
530
530
return false , state , nodeInfo , nil
531
531
}
@@ -535,7 +535,7 @@ func (g *genericScheduler) addNominatedPods(ctx context.Context, prof *profile.P
535
535
for _ , p := range nominatedPods {
536
536
if podutil .GetPodPriority (p ) >= podutil .GetPodPriority (pod ) && p .UID != pod .UID {
537
537
nodeInfoOut .AddPod (p )
538
- status := prof .RunPreFilterExtensionAddPod (ctx , stateOut , pod , p , nodeInfoOut )
538
+ status := pr .RunPreFilterExtensionAddPod (ctx , stateOut , pod , p , nodeInfoOut )
539
539
if ! status .IsSuccess () {
540
540
return false , state , nodeInfo , status .AsError ()
541
541
}
@@ -555,9 +555,10 @@ func (g *genericScheduler) addNominatedPods(ctx context.Context, prof *profile.P
555
555
// and add the nominated pods. Removal of the victims is done by
556
556
// SelectVictimsOnNode(). Preempt removes victims from PreFilter state and
557
557
// NodeInfo before calling this function.
558
- func ( g * genericScheduler ) podPassesFiltersOnNode (
558
+ func podPassesFiltersOnNode (
559
559
ctx context.Context ,
560
- prof * profile.Profile ,
560
+ pr framework.PluginsRunner ,
561
+ nominator framework.PodNominator ,
561
562
state * framework.CycleState ,
562
563
pod * v1.Pod ,
563
564
info * framework.NodeInfo ,
@@ -588,15 +589,15 @@ func (g *genericScheduler) podPassesFiltersOnNode(
588
589
nodeInfoToUse := info
589
590
if i == 0 {
590
591
var err error
591
- podsAdded , stateToUse , nodeInfoToUse , err = g . addNominatedPods (ctx , prof , pod , state , info )
592
+ podsAdded , stateToUse , nodeInfoToUse , err = addNominatedPods (ctx , pr , nominator , pod , state , info )
592
593
if err != nil {
593
594
return false , nil , err
594
595
}
595
596
} else if ! podsAdded || ! status .IsSuccess () {
596
597
break
597
598
}
598
599
599
- statusMap := prof .RunFilterPlugins (ctx , stateToUse , pod , nodeInfoToUse )
600
+ statusMap := pr .RunFilterPlugins (ctx , stateToUse , pod , nodeInfoToUse )
600
601
status = statusMap .Merge ()
601
602
if ! status .IsSuccess () && ! status .IsUnschedulable () {
602
603
return false , status , status .AsError ()
@@ -847,9 +848,10 @@ func pickOneNodeForPreemption(nodesToVictims map[string]*extenderv1.Victims) str
847
848
848
849
// selectNodesForPreemption finds all the nodes with possible victims for
849
850
// preemption in parallel.
850
- func ( g * genericScheduler ) selectNodesForPreemption (
851
+ func selectNodesForPreemption (
851
852
ctx context.Context ,
852
- prof * profile.Profile ,
853
+ pr framework.PluginsRunner ,
854
+ nominator framework.PodNominator ,
853
855
state * framework.CycleState ,
854
856
pod * v1.Pod ,
855
857
potentialNodes []* framework.NodeInfo ,
@@ -861,7 +863,7 @@ func (g *genericScheduler) selectNodesForPreemption(
861
863
checkNode := func (i int ) {
862
864
nodeInfoCopy := potentialNodes [i ].Clone ()
863
865
stateCopy := state .Clone ()
864
- pods , numPDBViolations , fits := g . selectVictimsOnNode (ctx , prof , stateCopy , pod , nodeInfoCopy , pdbs )
866
+ pods , numPDBViolations , fits := selectVictimsOnNode (ctx , pr , nominator , stateCopy , pod , nodeInfoCopy , pdbs )
865
867
if fits {
866
868
resultLock .Lock ()
867
869
victims := extenderv1.Victims {
@@ -937,9 +939,10 @@ func filterPodsWithPDBViolation(pods []*v1.Pod, pdbs []*policy.PodDisruptionBudg
937
939
// NOTE: This function assumes that it is never called if "pod" cannot be scheduled
938
940
// due to pod affinity, node affinity, or node anti-affinity reasons. None of
939
941
// these predicates can be satisfied by removing more pods from the node.
940
- func ( g * genericScheduler ) selectVictimsOnNode (
942
+ func selectVictimsOnNode (
941
943
ctx context.Context ,
942
- prof * profile.Profile ,
944
+ pr framework.PluginsRunner ,
945
+ nominator framework.PodNominator ,
943
946
state * framework.CycleState ,
944
947
pod * v1.Pod ,
945
948
nodeInfo * framework.NodeInfo ,
@@ -951,15 +954,15 @@ func (g *genericScheduler) selectVictimsOnNode(
951
954
if err := nodeInfo .RemovePod (rp ); err != nil {
952
955
return err
953
956
}
954
- status := prof .RunPreFilterExtensionRemovePod (ctx , state , pod , rp , nodeInfo )
957
+ status := pr .RunPreFilterExtensionRemovePod (ctx , state , pod , rp , nodeInfo )
955
958
if ! status .IsSuccess () {
956
959
return status .AsError ()
957
960
}
958
961
return nil
959
962
}
960
963
addPod := func (ap * v1.Pod ) error {
961
964
nodeInfo .AddPod (ap )
962
- status := prof .RunPreFilterExtensionAddPod (ctx , state , pod , ap , nodeInfo )
965
+ status := pr .RunPreFilterExtensionAddPod (ctx , state , pod , ap , nodeInfo )
963
966
if ! status .IsSuccess () {
964
967
return status .AsError ()
965
968
}
@@ -982,7 +985,7 @@ func (g *genericScheduler) selectVictimsOnNode(
982
985
// inter-pod affinity to one or more victims, but we have decided not to
983
986
// support this case for performance reasons. Having affinity to lower
984
987
// priority pods is not a recommended configuration anyway.
985
- if fits , _ , err := g . podPassesFiltersOnNode (ctx , prof , state , pod , nodeInfo ); ! fits {
988
+ if fits , _ , err := podPassesFiltersOnNode (ctx , pr , nominator , state , pod , nodeInfo ); ! fits {
986
989
if err != nil {
987
990
klog .Warningf ("Encountered error while selecting victims on node %v: %v" , nodeInfo .Node ().Name , err )
988
991
}
@@ -1000,7 +1003,7 @@ func (g *genericScheduler) selectVictimsOnNode(
1000
1003
if err := addPod (p ); err != nil {
1001
1004
return false , err
1002
1005
}
1003
- fits , _ , _ := g . podPassesFiltersOnNode (ctx , prof , state , pod , nodeInfo )
1006
+ fits , _ , _ := podPassesFiltersOnNode (ctx , pr , nominator , state , pod , nodeInfo )
1004
1007
if ! fits {
1005
1008
if err := removePod (p ); err != nil {
1006
1009
return false , err
0 commit comments