Ignore specific Pod update events in scheduler

This commit is contained in:
Wei Huang 2020-10-30 19:06:23 -07:00
parent 2e55fa82df
commit 6e0fb9ad7f
No known key found for this signature in database
GPG Key ID: BE5E9752F8B6E005

View File

@ -176,11 +176,16 @@ func (sched *Scheduler) addPodToSchedulingQueue(obj interface{}) {
}
func (sched *Scheduler) updatePodInSchedulingQueue(oldObj, newObj interface{}) {
pod := newObj.(*v1.Pod)
if sched.skipPodUpdate(pod) {
oldPod, newPod := oldObj.(*v1.Pod), newObj.(*v1.Pod)
// Bypass update event that carries identical objects; otherwise, a duplicated
// Pod may go through scheduling and cause unexpected behavior (see #96071).
if oldPod.ResourceVersion == newPod.ResourceVersion {
return
}
if err := sched.SchedulingQueue.Update(oldObj.(*v1.Pod), pod); err != nil {
if sched.skipPodUpdate(newPod) {
return
}
if err := sched.SchedulingQueue.Update(oldPod, newPod); err != nil {
utilruntime.HandleError(fmt.Errorf("unable to update %T: %v", newObj, err))
}
}