Fix scheduler cache inconsistency upon Pods with same name but different UIDs

Co-authored-by: Wei Huang <wei.huang1@ibm.com>
Co-authored-by: tianxia52 <871883758@qq.com>
This commit is contained in:
Wei Huang
2020-05-15 11:41:54 -07:00
parent ab207be846
commit 1b30105dac
3 changed files with 62 additions and 4 deletions

View File

@@ -243,6 +243,15 @@ func (sched *Scheduler) updatePodInCache(oldObj, newObj interface{}) {
return
}
// A Pod delete event followed by an immediate Pod add event may be merged
// into a Pod update event. In this case, we should invalidate the old Pod, and
// then add the new Pod.
if oldPod.UID != newPod.UID {
sched.deletePodFromCache(oldObj)
sched.addPodToCache(newObj)
return
}
// NOTE: Updates must be written to scheduler cache before invalidating
// equivalence cache, because we could snapshot equivalence cache after the
// invalidation and then snapshot the cache itself. If the cache is