mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 03:03:59 +00:00
Merge pull request #126465 from googs1025/podEligibleToPreemptOthers_refactor
feat: add ctx param for PodEligibleToPreemptOthers
This commit is contained in:
commit
e90364f45d
@ -236,7 +236,7 @@ func (pl *DefaultPreemption) SelectVictimsOnNode(
|
||||
// 2. The pod has already preempted other pods and the victims are in their graceful termination period.
|
||||
// Currently we check the node that is nominated for this pod, and as long as there are
|
||||
// terminating pods on this node, we don't attempt to preempt more pods.
|
||||
func (pl *DefaultPreemption) PodEligibleToPreemptOthers(pod *v1.Pod, nominatedNodeStatus *framework.Status) (bool, string) {
|
||||
func (pl *DefaultPreemption) PodEligibleToPreemptOthers(_ context.Context, pod *v1.Pod, nominatedNodeStatus *framework.Status) (bool, string) {
|
||||
if pod.Spec.PreemptionPolicy != nil && *pod.Spec.PreemptionPolicy == v1.PreemptNever {
|
||||
return false, "not eligible due to preemptionPolicy=Never."
|
||||
}
|
||||
|
@ -1500,7 +1500,7 @@ func TestPodEligibleToPreemptOthers(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
pl := DefaultPreemption{fh: f, fts: test.fts}
|
||||
if got, _ := pl.PodEligibleToPreemptOthers(test.pod, test.nominatedNodeStatus); got != test.expected {
|
||||
if got, _ := pl.PodEligibleToPreemptOthers(ctx, test.pod, test.nominatedNodeStatus); got != test.expected {
|
||||
t.Errorf("expected %t, got %t for pod: %s", test.expected, got, test.pod.Name)
|
||||
}
|
||||
})
|
||||
|
@ -108,7 +108,7 @@ type Interface interface {
|
||||
CandidatesToVictimsMap(candidates []Candidate) map[string]*extenderv1.Victims
|
||||
// PodEligibleToPreemptOthers returns one bool and one string. The bool indicates whether this pod should be considered for
|
||||
// preempting other pods or not. The string includes the reason if this pod isn't eligible.
|
||||
PodEligibleToPreemptOthers(pod *v1.Pod, nominatedNodeStatus *framework.Status) (bool, string)
|
||||
PodEligibleToPreemptOthers(ctx context.Context, pod *v1.Pod, nominatedNodeStatus *framework.Status) (bool, string)
|
||||
// SelectVictimsOnNode finds minimum set of pods on the given node that should be preempted in order to make enough room
|
||||
// for "pod" to be scheduled.
|
||||
// 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
|
||||
|
||||
// 1) Ensure the preemptor is eligible to preempt other pods.
|
||||
nominatedNodeStatus := m.Get(pod.Status.NominatedNodeName)
|
||||
if ok, msg := ev.PodEligibleToPreemptOthers(pod, nominatedNodeStatus); !ok {
|
||||
if ok, msg := ev.PodEligibleToPreemptOthers(ctx, pod, nominatedNodeStatus); !ok {
|
||||
logger.V(5).Info("Pod is not eligible for preemption", "pod", klog.KObj(pod), "reason", msg)
|
||||
return nil, framework.NewStatus(framework.Unschedulable, msg)
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ func (pl *FakePostFilterPlugin) CandidatesToVictimsMap(candidates []Candidate) m
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pl *FakePostFilterPlugin) PodEligibleToPreemptOthers(pod *v1.Pod, nominatedNodeStatus *framework.Status) (bool, string) {
|
||||
func (pl *FakePostFilterPlugin) PodEligibleToPreemptOthers(_ context.Context, pod *v1.Pod, nominatedNodeStatus *framework.Status) (bool, string) {
|
||||
return true, ""
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ func (pl *FakePreemptionScorePostFilterPlugin) CandidatesToVictimsMap(candidates
|
||||
return m
|
||||
}
|
||||
|
||||
func (pl *FakePreemptionScorePostFilterPlugin) PodEligibleToPreemptOthers(pod *v1.Pod, nominatedNodeStatus *framework.Status) (bool, string) {
|
||||
func (pl *FakePreemptionScorePostFilterPlugin) PodEligibleToPreemptOthers(_ context.Context, pod *v1.Pod, nominatedNodeStatus *framework.Status) (bool, string) {
|
||||
return true, ""
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user