Add function NominatedPodsForNode to PodNominator interface.

- replace SchedulingQueue with PodNominator in genericScheduler.
This commit is contained in:
Wei Huang
2020-05-20 11:38:21 -07:00
parent eb34058777
commit f4b726237a
6 changed files with 20 additions and 28 deletions

View File

@@ -83,7 +83,6 @@ type SchedulingQueue interface {
MoveAllToActiveOrBackoffQueue(event string)
AssignedPodAdded(pod *v1.Pod)
AssignedPodUpdated(pod *v1.Pod)
NominatedPodsForNode(nodeName string) []*v1.Pod
PendingPods() []*v1.Pod
// Close closes the SchedulingQueue so that the goroutine which is
// waiting to pop items can exit gracefully.
@@ -556,14 +555,6 @@ func (p *PriorityQueue) getUnschedulablePodsWithMatchingAffinityTerm(pod *v1.Pod
return podsToMove
}
// NominatedPodsForNode returns pods that are nominated to run on the given node,
// but they are waiting for other pods to be removed from the node before they
// can be actually scheduled.
func (p *PriorityQueue) NominatedPodsForNode(nodeName string) []*v1.Pod {
// TODO: make podsForNode() public?
return p.PodNominator.(*nominatedPodMap).podsForNode(nodeName)
}
// PendingPods returns all the pending pods in the queue. This function is
// used for debugging purposes in the scheduler cache dumper and comparer.
func (p *PriorityQueue) PendingPods() []*v1.Pod {
@@ -608,6 +599,16 @@ func (npm *nominatedPodMap) AddNominatedPod(pod *v1.Pod, nodeName string) {
npm.Unlock()
}
// NominatedPodsForNode returns pods that are nominated to run on the given node,
// but they are waiting for other pods to be removed from the node.
func (npm *nominatedPodMap) NominatedPodsForNode(nodeName string) []*v1.Pod {
npm.RLock()
defer npm.RUnlock()
// TODO: we may need to return a copy of []*Pods to avoid modification
// on the caller side.
return npm.nominatedPods[nodeName]
}
func (p *PriorityQueue) podsCompareBackoffCompleted(podInfo1, podInfo2 interface{}) bool {
pInfo1 := podInfo1.(*framework.QueuedPodInfo)
pInfo2 := podInfo2.(*framework.QueuedPodInfo)
@@ -794,15 +795,6 @@ func (npm *nominatedPodMap) UpdateNominatedPod(oldPod, newPod *v1.Pod) {
npm.add(newPod, nodeName)
}
func (npm *nominatedPodMap) podsForNode(nodeName string) []*v1.Pod {
npm.RLock()
defer npm.RUnlock()
if list, ok := npm.nominatedPods[nodeName]; ok {
return list
}
return nil
}
// NewPodNominator creates a nominatedPodMap as a backing of framework.PodNominator.
func NewPodNominator() framework.PodNominator {
return &nominatedPodMap{