Skip to content

Commit 82f5531

Browse files
authored
Merge pull request kubernetes#82119 from wgliang/fixbug/fix-scheudle-function-context
Take the context as the first argument of Schedule
2 parents 3f33bfd + 008f4e2 commit 82f5531

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

pkg/scheduler/core/extender_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
555555
schedulerapi.DefaultPercentageOfNodesToScore,
556556
false)
557557
podIgnored := &v1.Pod{}
558-
result, err := scheduler.Schedule(podIgnored, framework.NewPluginContext())
558+
result, err := scheduler.Schedule(framework.NewPluginContext(), podIgnored)
559559
if test.expectsErr {
560560
if err == nil {
561561
t.Errorf("Unexpected non-error, result %+v", result)

pkg/scheduler/core/generic_scheduler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func (f *FitError) Error() string {
132132
// onto machines.
133133
// TODO: Rename this type.
134134
type ScheduleAlgorithm interface {
135-
Schedule(*v1.Pod, *framework.PluginContext) (scheduleResult ScheduleResult, err error)
135+
Schedule(*framework.PluginContext, *v1.Pod) (scheduleResult ScheduleResult, err error)
136136
// Preempt receives scheduling errors for a pod and tries to create room for
137137
// the pod by preempting lower priority pods if possible.
138138
// It returns the node where preemption happened, a list of preempted pods, a
@@ -186,7 +186,7 @@ func (g *genericScheduler) snapshot() error {
186186
// Schedule tries to schedule the given pod to one of the nodes in the node list.
187187
// If it succeeds, it will return the name of the node.
188188
// If it fails, it will return a FitError error with reasons.
189-
func (g *genericScheduler) Schedule(pod *v1.Pod, pluginContext *framework.PluginContext) (result ScheduleResult, err error) {
189+
func (g *genericScheduler) Schedule(pluginContext *framework.PluginContext, pod *v1.Pod) (result ScheduleResult, err error) {
190190
trace := utiltrace.New("Scheduling", utiltrace.Field{Key: "namespace", Value: pod.Namespace}, utiltrace.Field{Key: "name", Value: pod.Name})
191191
defer trace.LogIfLong(100 * time.Millisecond)
192192

pkg/scheduler/core/generic_scheduler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ func TestGenericScheduler(t *testing.T) {
673673
false,
674674
schedulerapi.DefaultPercentageOfNodesToScore,
675675
false)
676-
result, err := scheduler.Schedule(test.pod, framework.NewPluginContext())
676+
result, err := scheduler.Schedule(framework.NewPluginContext(), test.pod)
677677
if !reflect.DeepEqual(err, test.wErr) {
678678
t.Errorf("Unexpected error: %v, expected: %v", err.Error(), test.wErr)
679679
}

pkg/scheduler/scheduler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ func (sched *Scheduler) recordSchedulingFailure(pod *v1.Pod, err error, reason s
337337
// schedule implements the scheduling algorithm and returns the suggested result(host,
338338
// evaluated nodes number,feasible nodes number).
339339
func (sched *Scheduler) schedule(pod *v1.Pod, pluginContext *framework.PluginContext) (core.ScheduleResult, error) {
340-
result, err := sched.Algorithm.Schedule(pod, pluginContext)
340+
result, err := sched.Algorithm.Schedule(pluginContext, pod)
341341
if err != nil {
342342
pod = pod.DeepCopy()
343343
sched.recordSchedulingFailure(pod, err, v1.PodReasonUnschedulable, err.Error())

pkg/scheduler/scheduler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ type mockScheduler struct {
153153
err error
154154
}
155155

156-
func (es mockScheduler) Schedule(pod *v1.Pod, pc *framework.PluginContext) (core.ScheduleResult, error) {
156+
func (es mockScheduler) Schedule(pc *framework.PluginContext, pod *v1.Pod) (core.ScheduleResult, error) {
157157
return es.result, es.err
158158
}
159159

0 commit comments

Comments
 (0)