GC waits for all reflectors to be synced before starts workers
This commit is contained in:
		| @@ -684,10 +684,22 @@ func (gc *GarbageCollector) processItem(item *node) error { | ||||
| } | ||||
|  | ||||
| func (gc *GarbageCollector) Run(workers int, stopCh <-chan struct{}) { | ||||
| 	glog.Infof("Garbage Collector: Initializing") | ||||
| 	for _, monitor := range gc.monitors { | ||||
| 		go monitor.controller.Run(stopCh) | ||||
| 	} | ||||
|  | ||||
| 	wait.PollInfinite(10*time.Second, func() (bool, error) { | ||||
| 		for _, monitor := range gc.monitors { | ||||
| 			if !monitor.controller.HasSynced() { | ||||
| 				glog.Infof("Garbage Collector: Waiting for resource monitors to be synced...") | ||||
| 				return false, nil | ||||
| 			} | ||||
| 		} | ||||
| 		return true, nil | ||||
| 	}) | ||||
| 	glog.Infof("Garbage Collector: All monitored resources synced. Proceeding to collect garbage") | ||||
|  | ||||
| 	// worker | ||||
| 	go wait.Until(gc.propagator.processEvent, 0, stopCh) | ||||
|  | ||||
| @@ -696,7 +708,7 @@ func (gc *GarbageCollector) Run(workers int, stopCh <-chan struct{}) { | ||||
| 		go wait.Until(gc.orphanFinalizer, 0, stopCh) | ||||
| 	} | ||||
| 	<-stopCh | ||||
| 	glog.Infof("Shutting down garbage collector") | ||||
| 	glog.Infof("Garbage Collector: Shutting down") | ||||
| 	gc.dirtyQueue.ShutDown() | ||||
| 	gc.orphanQueue.ShutDown() | ||||
| 	gc.propagator.eventQueue.ShutDown() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Chao Xu
					Chao Xu