// Run will set up the event handlers for types we are interested in, as well as syncing informer caches and starting
// workers. It will block until stopCh is closed, at which point it will shutdown the workqueue and wait for workers
// to finish processing their current work items.
Run will set up the event handlers for types we are interested in, as well as syncing informer caches and starting
workers. It will block until stopCh is closed, at which point it will shutdown the workqueue and wait for workers
to finish processing their current work items.
// Run will set up the event handlers for types we are interested in as well as syncing informer caches and starting // workers . It will block until stopCh is closed at which point it will shutdown the workqueue and wait for workers // to finish processing their current work items .
func (c *Controller) Run(threadiness int, stopCh <-chan struct{}) error {
	defer utilruntime.HandleCrash()
	defer c.workqueue.ShutDown()
	klog.Info("Starting Apimanager controller")
	klog.Info("Waiting for informer caches to sync")
	if ok := cache.WaitForCacheSync(stopCh, c.deploymentsSynced, c.apimanagersSynced); !ok {
		return fmt.Errorf("failed to wait for caches to sync")
	}
	klog.Info("Starting workers")
	for i := 0; i < threadiness; i++ {
		go wait.Until(c.runWorker, time.Second, stopCh)
	}
	klog.Info("Started workers")
	<-stopCh
	klog.Info("Shutting down workers")
	return nil
}
func ( c * Controller ) Run ( threadiness int , stopCh <- chan struct { } ) error { defer utilruntime . HandleCrash ( ) defer c . workqueue . ShutDown ( ) klog . Info ( " " ) klog . Info ( " " ) if ok := cache . WaitForCacheSync ( stopCh , c . deploymentsSynced , c . apimanagersSynced ) ; ! ok { return fmt . Errorf ( " " ) } klog . Info ( " " ) for i := 0 ; i < threadiness ; i ++ { go wait . Until ( c . runWorker , time . Second , stopCh ) } klog . Info ( " " ) <- stopCh klog . Info ( " " ) return nil }
Run will set up the event handlers for types we are interested in, as well as syncing informer caches and starting
workers.
Run will set up the event handlers for types we are interested in as well as syncing informer caches and starting workers .
// Start the informer factories to begin populating the informer caches // Wait for the caches to be synced before starting workers //if controller is down and then once its up, controller query api server for objects, so it has to wait for objects in cache to sync // Launch two workers to process Apimanager resources