Watch for started informers in factory.start
This commit is contained in:
		@@ -46,7 +46,11 @@ type sharedInformerFactory struct {
 | 
			
		||||
	client        clientset.Interface
 | 
			
		||||
	lock          sync.Mutex
 | 
			
		||||
	defaultResync time.Duration
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
@@ -55,6 +59,7 @@ func NewSharedInformerFactory(client clientset.Interface, defaultResync time.Dur
 | 
			
		||||
		client:           client,
 | 
			
		||||
		defaultResync:    defaultResync,
 | 
			
		||||
		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()
 | 
			
		||||
	defer s.lock.Unlock()
 | 
			
		||||
 | 
			
		||||
	for _, informer := range s.informers {
 | 
			
		||||
	for informerType, informer := range s.informers {
 | 
			
		||||
		if !s.startedInformers[informerType] {
 | 
			
		||||
			go informer.Run(stopCh)
 | 
			
		||||
			s.startedInformers[informerType] = true
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user