-
Notifications
You must be signed in to change notification settings - Fork 426
Description
The events registered in the scheduler's start function return and start scheduling before the callbacks of event are completed. This may cause some resources and status to be incompletely initialized, leading to scheduling problems. For example, when there are a large number of Pods, it is possible that the status of the quotaManager may not be synchronized.
HAMi/pkg/scheduler/scheduler.go
Lines 194 to 209 in 5e38dc3
| informerFactory.Core().V1().Pods().Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ | |
| AddFunc: s.onAddPod, | |
| UpdateFunc: s.onUpdatePod, | |
| DeleteFunc: s.onDelPod, | |
| }) | |
| informerFactory.Core().V1().Nodes().Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ | |
| AddFunc: func(_ any) { s.doNodeNotify() }, | |
| DeleteFunc: s.onDelNode, | |
| }) | |
| informerFactory.Core().V1().ResourceQuotas().Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ | |
| AddFunc: s.onAddQuota, | |
| UpdateFunc: s.onUpdateQuota, | |
| DeleteFunc: s.onDelQuota, | |
| }) | |
| informerFactory.Start(s.stopCh) | |
| informerFactory.WaitForCacheSync(s.stopCh) |
In the WaitForCacheSync function, for each informer, cache.WaitForCacheSync(stopCh, informer.HasSynced) is called. This means it waits until the HasSynced method of each informer returns true before returning.
for informType, informer := range informers {
res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced)
}In the function declaration of HasSynced in SharedInformer interface, we can see the following description:
// HasSynced returns true if the shared informer's store has been
// informed by at least one full LIST of the authoritative state
// of the informer's object collection. This is unrelated to "resync".
//
// Note that this doesn't tell you if an individual handler is synced!!
// For that, please call HasSynced on the handle returned by
// AddEventHandler.
HasSynced() boolThis means that the completion of the WaitForCacheSync function does not guarantee that all event callbacks have finished.