change AddEventHandlerWithResyncPeriod to AddEventHandler in factory.go

Signed-off-by: zhangjie <zhangjie0619@yeah.net>
This commit is contained in:
zhangjie 2017-08-30 10:18:00 +08:00
parent 4457e43e7b
commit 301d41cac8

View File

@ -207,48 +207,44 @@ func NewConfigFactory(
c.scheduledPodLister = assignedPodLister{podInformer.Lister()} c.scheduledPodLister = assignedPodLister{podInformer.Lister()}
// Only nodes in the "Ready" condition with status == "True" are schedulable // Only nodes in the "Ready" condition with status == "True" are schedulable
nodeInformer.Informer().AddEventHandlerWithResyncPeriod( nodeInformer.Informer().AddEventHandler(
cache.ResourceEventHandlerFuncs{ cache.ResourceEventHandlerFuncs{
AddFunc: c.addNodeToCache, AddFunc: c.addNodeToCache,
UpdateFunc: c.updateNodeInCache, UpdateFunc: c.updateNodeInCache,
DeleteFunc: c.deleteNodeFromCache, DeleteFunc: c.deleteNodeFromCache,
}, },
0,
) )
c.nodeLister = nodeInformer.Lister() c.nodeLister = nodeInformer.Lister()
// On add and delete of PVs, it will affect equivalence cache items // On add and delete of PVs, it will affect equivalence cache items
// related to persistent volume // related to persistent volume
pvInformer.Informer().AddEventHandlerWithResyncPeriod( pvInformer.Informer().AddEventHandler(
cache.ResourceEventHandlerFuncs{ cache.ResourceEventHandlerFuncs{
// MaxPDVolumeCountPredicate: since it relies on the counts of PV. // MaxPDVolumeCountPredicate: since it relies on the counts of PV.
AddFunc: c.onPvAdd, AddFunc: c.onPvAdd,
DeleteFunc: c.onPvDelete, DeleteFunc: c.onPvDelete,
}, },
0,
) )
c.pVLister = pvInformer.Lister() c.pVLister = pvInformer.Lister()
// This is for MaxPDVolumeCountPredicate: add/delete PVC will affect counts of PV when it is bound. // This is for MaxPDVolumeCountPredicate: add/delete PVC will affect counts of PV when it is bound.
pvcInformer.Informer().AddEventHandlerWithResyncPeriod( pvcInformer.Informer().AddEventHandler(
cache.ResourceEventHandlerFuncs{ cache.ResourceEventHandlerFuncs{
AddFunc: c.onPvcAdd, AddFunc: c.onPvcAdd,
DeleteFunc: c.onPvcDelete, DeleteFunc: c.onPvcDelete,
}, },
0,
) )
c.pVCLister = pvcInformer.Lister() c.pVCLister = pvcInformer.Lister()
// This is for ServiceAffinity: affected by the selector of the service is updated. // This is for ServiceAffinity: affected by the selector of the service is updated.
// Also, if new service is added, equivalence cache will also become invalid since // Also, if new service is added, equivalence cache will also become invalid since
// existing pods may be "captured" by this service and change this predicate result. // existing pods may be "captured" by this service and change this predicate result.
serviceInformer.Informer().AddEventHandlerWithResyncPeriod( serviceInformer.Informer().AddEventHandler(
cache.ResourceEventHandlerFuncs{ cache.ResourceEventHandlerFuncs{
AddFunc: c.onServiceAdd, AddFunc: c.onServiceAdd,
UpdateFunc: c.onServiceUpdate, UpdateFunc: c.onServiceUpdate,
DeleteFunc: c.onServiceDelete, DeleteFunc: c.onServiceDelete,
}, },
0,
) )
c.serviceLister = serviceInformer.Lister() c.serviceLister = serviceInformer.Lister()