preempt
kube-scheduler源码分析(六)之 preempt
1. 调用入口
// scheduleOne does the entire scheduling workflow for a single pod. It is serialized on the scheduling algorithm's host fitting.
func (sched *Scheduler) scheduleOne() {
...
suggestedHost, err := sched.schedule(pod)
if err != nil {
// schedule() may have failed because the pod would not fit on any host, so we try to
// preempt, with the expectation that the next time the pod is tried for scheduling it
// will fit due to the preemption. It is also possible that a different pod will schedule
// into the resources that were preempted, but this is harmless.
if fitError, ok := err.(*core.FitError); ok {
preemptionStartTime := time.Now()
// 执行抢占逻辑
sched.preempt(pod, fitError)
metrics.PreemptionAttempts.Inc()
metrics.SchedulingAlgorithmPremptionEvaluationDuration.Observe(metrics.SinceInMicroseconds(preemptionStartTime))
metrics.SchedulingLatency.WithLabelValues(metrics.PreemptionEvaluation).Observe(metrics.SinceInSeconds(preemptionStartTime))
}
return
}
...
} 2. Scheduler.preempt
2.1. preempt
2.2. NominatedNodeName
3. genericScheduler.Preempt
3.1. selectNodesForPreemption
3.1.1. selectVictimsOnNode
3.2. processPreemptionWithExtenders
3.3. pickOneNodeForPreemption
3.4. getLowerPriorityNominatedPods
4. 总结
4.1. Scheduler.preempt
4.2. genericScheduler.Preempt
最后更新于