mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +00:00
Merge pull request #72632 from danielqsj/sch_pod
Move getNextPod to closure
This commit is contained in:
commit
db60e4f20c
@ -900,9 +900,7 @@ func (c *configFactory) CreateFromKeys(predicateKeys, priorityKeys sets.String,
|
|||||||
WaitForCacheSync: func() bool {
|
WaitForCacheSync: func() bool {
|
||||||
return cache.WaitForCacheSync(c.StopEverything, c.scheduledPodsHasSynced)
|
return cache.WaitForCacheSync(c.StopEverything, c.scheduledPodsHasSynced)
|
||||||
},
|
},
|
||||||
NextPod: func() *v1.Pod {
|
NextPod: internalqueue.MakeNextPodFunc(c.podQueue),
|
||||||
return c.getNextPod()
|
|
||||||
},
|
|
||||||
Error: c.MakeDefaultErrorFunc(podBackoff, c.podQueue),
|
Error: c.MakeDefaultErrorFunc(podBackoff, c.podQueue),
|
||||||
StopEverything: c.StopEverything,
|
StopEverything: c.StopEverything,
|
||||||
VolumeBinder: c.volumeBinder,
|
VolumeBinder: c.volumeBinder,
|
||||||
@ -971,16 +969,6 @@ func (c *configFactory) getPluginArgs() (*PluginFactoryArgs, error) {
|
|||||||
}, nil
|
}, 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).
|
// assignedPod selects pods that are assigned (scheduled and running).
|
||||||
func assignedPod(pod *v1.Pod) bool {
|
func assignedPod(pod *v1.Pod) bool {
|
||||||
return len(pod.Spec.NodeName) != 0
|
return len(pod.Spec.NodeName) != 0
|
||||||
|
@ -811,3 +811,17 @@ func newNominatedPodMap() *nominatedPodMap {
|
|||||||
nominatedPodToNode: make(map[ktypes.UID]string),
|
nominatedPodToNode: make(map[ktypes.UID]string),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MakeNextPodFunc returns a function to retrieve the next pod from a given
|
||||||
|
// scheduling queue
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user