mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
Watch for started informers in factory.start
This commit is contained in:
parent
52559696e9
commit
3afd822537
@ -46,15 +46,20 @@ type sharedInformerFactory struct {
|
|||||||
client clientset.Interface
|
client clientset.Interface
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
defaultResync time.Duration
|
defaultResync time.Duration
|
||||||
informers map[reflect.Type]framework.SharedIndexInformer
|
|
||||||
|
informers map[reflect.Type]framework.SharedIndexInformer
|
||||||
|
// startedInformers is used for tracking which informers have been started
|
||||||
|
// this allows calling of Start method multiple times
|
||||||
|
startedInformers map[reflect.Type]bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSharedInformerFactory constructs a new instance of sharedInformerFactory
|
// NewSharedInformerFactory constructs a new instance of sharedInformerFactory
|
||||||
func NewSharedInformerFactory(client clientset.Interface, defaultResync time.Duration) SharedInformerFactory {
|
func NewSharedInformerFactory(client clientset.Interface, defaultResync time.Duration) SharedInformerFactory {
|
||||||
return &sharedInformerFactory{
|
return &sharedInformerFactory{
|
||||||
client: client,
|
client: client,
|
||||||
defaultResync: defaultResync,
|
defaultResync: defaultResync,
|
||||||
informers: make(map[reflect.Type]framework.SharedIndexInformer),
|
informers: make(map[reflect.Type]framework.SharedIndexInformer),
|
||||||
|
startedInformers: make(map[reflect.Type]bool),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,8 +68,11 @@ func (s *sharedInformerFactory) Start(stopCh <-chan struct{}) {
|
|||||||
s.lock.Lock()
|
s.lock.Lock()
|
||||||
defer s.lock.Unlock()
|
defer s.lock.Unlock()
|
||||||
|
|
||||||
for _, informer := range s.informers {
|
for informerType, informer := range s.informers {
|
||||||
go informer.Run(stopCh)
|
if !s.startedInformers[informerType] {
|
||||||
|
go informer.Run(stopCh)
|
||||||
|
s.startedInformers[informerType] = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user