Skip to content

Commit fc0fcd0

Browse files
committed
feat: add ctx param for PodEligibleToPreemptOthers
1 parent 201bdaa commit fc0fcd0

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

pkg/scheduler/framework/plugins/defaultpreemption/default_preemption.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ func (pl *DefaultPreemption) SelectVictimsOnNode(
236236
// 2. The pod has already preempted other pods and the victims are in their graceful termination period.
237237
// Currently we check the node that is nominated for this pod, and as long as there are
238238
// terminating pods on this node, we don't attempt to preempt more pods.
239-
func (pl *DefaultPreemption) PodEligibleToPreemptOthers(pod *v1.Pod, nominatedNodeStatus *framework.Status) (bool, string) {
239+
func (pl *DefaultPreemption) PodEligibleToPreemptOthers(_ context.Context, pod *v1.Pod, nominatedNodeStatus *framework.Status) (bool, string) {
240240
if pod.Spec.PreemptionPolicy != nil && *pod.Spec.PreemptionPolicy == v1.PreemptNever {
241241
return false, "not eligible due to preemptionPolicy=Never."
242242
}

pkg/scheduler/framework/plugins/defaultpreemption/default_preemption_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1500,7 +1500,7 @@ func TestPodEligibleToPreemptOthers(t *testing.T) {
15001500
t.Fatal(err)
15011501
}
15021502
pl := DefaultPreemption{fh: f, fts: test.fts}
1503-
if got, _ := pl.PodEligibleToPreemptOthers(test.pod, test.nominatedNodeStatus); got != test.expected {
1503+
if got, _ := pl.PodEligibleToPreemptOthers(ctx, test.pod, test.nominatedNodeStatus); got != test.expected {
15041504
t.Errorf("expected %t, got %t for pod: %s", test.expected, got, test.pod.Name)
15051505
}
15061506
})

pkg/scheduler/framework/preemption/preemption.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ type Interface interface {
108108
CandidatesToVictimsMap(candidates []Candidate) map[string]*extenderv1.Victims
109109
// PodEligibleToPreemptOthers returns one bool and one string. The bool indicates whether this pod should be considered for
110110
// preempting other pods or not. The string includes the reason if this pod isn't eligible.
111-
PodEligibleToPreemptOthers(pod *v1.Pod, nominatedNodeStatus *framework.Status) (bool, string)
111+
PodEligibleToPreemptOthers(ctx context.Context, pod *v1.Pod, nominatedNodeStatus *framework.Status) (bool, string)
112112
// SelectVictimsOnNode finds minimum set of pods on the given node that should be preempted in order to make enough room
113113
// for "pod" to be scheduled.
114114
// Note that both `state` and `nodeInfo` are deep copied.
@@ -161,7 +161,7 @@ func (ev *Evaluator) Preempt(ctx context.Context, pod *v1.Pod, m framework.NodeT
161161

162162
// 1) Ensure the preemptor is eligible to preempt other pods.
163163
nominatedNodeStatus := m.Get(pod.Status.NominatedNodeName)
164-
if ok, msg := ev.PodEligibleToPreemptOthers(pod, nominatedNodeStatus); !ok {
164+
if ok, msg := ev.PodEligibleToPreemptOthers(ctx, pod, nominatedNodeStatus); !ok {
165165
logger.V(5).Info("Pod is not eligible for preemption", "pod", klog.KObj(pod), "reason", msg)
166166
return nil, framework.NewStatus(framework.Unschedulable, msg)
167167
}

pkg/scheduler/framework/preemption/preemption_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (pl *FakePostFilterPlugin) CandidatesToVictimsMap(candidates []Candidate) m
6767
return nil
6868
}
6969

70-
func (pl *FakePostFilterPlugin) PodEligibleToPreemptOthers(pod *v1.Pod, nominatedNodeStatus *framework.Status) (bool, string) {
70+
func (pl *FakePostFilterPlugin) PodEligibleToPreemptOthers(_ context.Context, pod *v1.Pod, nominatedNodeStatus *framework.Status) (bool, string) {
7171
return true, ""
7272
}
7373

@@ -95,7 +95,7 @@ func (pl *FakePreemptionScorePostFilterPlugin) CandidatesToVictimsMap(candidates
9595
return m
9696
}
9797

98-
func (pl *FakePreemptionScorePostFilterPlugin) PodEligibleToPreemptOthers(pod *v1.Pod, nominatedNodeStatus *framework.Status) (bool, string) {
98+
func (pl *FakePreemptionScorePostFilterPlugin) PodEligibleToPreemptOthers(_ context.Context, pod *v1.Pod, nominatedNodeStatus *framework.Status) (bool, string) {
9999
return true, ""
100100
}
101101

0 commit comments

Comments
 (0)