Enable propagration of HasSynced

* Add tracker types and tests
* Modify ResourceEventHandler interface's OnAdd member
* Add additional ResourceEventHandlerDetailedFuncs struct
* Fix SharedInformer to let users track HasSynced for their handlers
* Fix in-tree controllers which weren't computing HasSynced correctly
* Deprecate the cache.Pop function
This commit is contained in:
Daniel Smith
2022-11-18 00:12:50 +00:00
parent 4b27077eb2
commit 8100efc7b3
23 changed files with 653 additions and 175 deletions

View File

@@ -44,30 +44,26 @@ func AddGraphEventHandlers(
graph: graph,
}
var hasSynced []cache.InformerSynced
pods.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
podHandler, _ := pods.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: g.addPod,
UpdateFunc: g.updatePod,
DeleteFunc: g.deletePod,
})
hasSynced = append(hasSynced, pods.Informer().HasSynced)
pvs.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
pvsHandler, _ := pvs.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: g.addPV,
UpdateFunc: g.updatePV,
DeleteFunc: g.deletePV,
})
hasSynced = append(hasSynced, pvs.Informer().HasSynced)
attachments.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
attachHandler, _ := attachments.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: g.addVolumeAttachment,
UpdateFunc: g.updateVolumeAttachment,
DeleteFunc: g.deleteVolumeAttachment,
})
hasSynced = append(hasSynced, attachments.Informer().HasSynced)
go cache.WaitForNamedCacheSync("node_authorizer", wait.NeverStop, hasSynced...)
go cache.WaitForNamedCacheSync("node_authorizer", wait.NeverStop,
podHandler.HasSynced, pvsHandler.HasSynced, attachHandler.HasSynced)
}
func (g *graphPopulator) addPod(obj interface{}) {