Extract logic related with scheduler nominatedPods to an interface

- rename `UpdateNominatedPodForNode` to `AddNominatedPod`
- promote `update` to `UpdateNominatedPod`
- anonymous lock in nominatedMap
- pass PodNominator as an option to NewFramework
This commit is contained in:
Wei Huang
2020-05-18 10:29:08 -07:00
parent a3d532a3f7
commit bd184035c4
9 changed files with 128 additions and 78 deletions

View File

@@ -495,3 +495,19 @@ type FrameworkHandle interface {
// VolumeBinder returns the volume binder used by scheduler.
VolumeBinder() scheduling.SchedulerVolumeBinder
}
// PreemptHandle incorporates all needed logic to run preemption logic.
type PreemptHandle interface {
PodNominator
}
// PodNominator abstracts operations to maintain nominated Pods.
type PodNominator interface {
// AddNominatedPod adds the given pod to the nominated pod map or
// updates it if it already exists.
AddNominatedPod(pod *v1.Pod, nodeName string)
// DeleteNominatedPodIfExists deletes nominatedPod from internal cache. It's a no-op if it doesn't exist.
DeleteNominatedPodIfExists(pod *v1.Pod)
// UpdateNominatedPod updates the <oldPod> with <newPod>.
UpdateNominatedPod(oldPod, newPod *v1.Pod)
}