diff --git a/pkg/scheduler/factory/factory.go b/pkg/scheduler/factory/factory.go index c533235608..7d26e19965 100644 --- a/pkg/scheduler/factory/factory.go +++ b/pkg/scheduler/factory/factory.go @@ -901,9 +901,7 @@ func (c *configFactory) CreateFromKeys(predicateKeys, priorityKeys sets.String, WaitForCacheSync: func() bool { return cache.WaitForCacheSync(c.StopEverything, c.scheduledPodsHasSynced) }, - NextPod: func() *v1.Pod { - return c.getNextPod() - }, + NextPod: internalqueue.MakeNextPodFunc(c.podQueue), Error: c.MakeDefaultErrorFunc(podBackoff, c.podQueue), StopEverything: c.StopEverything, VolumeBinder: c.volumeBinder, @@ -972,16 +970,6 @@ func (c *configFactory) getPluginArgs() (*PluginFactoryArgs, error) { }, nil } -func (c *configFactory) getNextPod() *v1.Pod { - pod, err := c.podQueue.Pop() - if err == nil { - klog.V(4).Infof("About to try and schedule pod %v/%v", pod.Namespace, pod.Name) - return pod - } - klog.Errorf("Error while retrieving next pod from scheduling queue: %v", err) - return nil -} - // assignedPod selects pods that are assigned (scheduled and running). func assignedPod(pod *v1.Pod) bool { return len(pod.Spec.NodeName) != 0 diff --git a/pkg/scheduler/internal/queue/scheduling_queue.go b/pkg/scheduler/internal/queue/scheduling_queue.go index 17e17abe82..0278d5833d 100644 --- a/pkg/scheduler/internal/queue/scheduling_queue.go +++ b/pkg/scheduler/internal/queue/scheduling_queue.go @@ -808,3 +808,15 @@ func newNominatedPodMap() *nominatedPodMap { nominatedPodToNode: make(map[ktypes.UID]string), } } + +func MakeNextPodFunc(queue SchedulingQueue) func() *v1.Pod { + return func() *v1.Pod { + pod, err := queue.Pop() + if err == nil { + klog.V(4).Infof("About to try and schedule pod %v/%v", pod.Namespace, pod.Name) + return pod + } + klog.Errorf("Error while retrieving next pod from scheduling queue: %v", err) + return nil + } +}