update GC controller to wait until controllers have been initialized once

This commit is contained in:
David Eads
2017-08-24 12:39:55 -04:00
parent 4a6bbb9f50
commit 253b047d89
6 changed files with 30 additions and 3 deletions

View File

@@ -78,6 +78,10 @@ type GraphBuilder struct {
// dependencyGraphBuilder
monitors monitors
monitorLock sync.Mutex
// informersStarted is closed after after all of the controllers have been initialized and are running.
// After that it is safe to start them here, before that it is not.
informersStarted <-chan struct{}
// stopCh drives shutdown. If it is nil, it indicates that Run() has not been
// called yet. If it is non-nil, then when closed it indicates everything
// should shut down.
@@ -279,6 +283,10 @@ func (gb *GraphBuilder) startMonitors() {
return
}
// we're waiting until after the informer start that happens once all the controllers are initialized. This ensures
// that they don't get unexpected events on their work queues.
<-gb.informersStarted
monitors := gb.monitors
started := 0
for _, monitor := range monitors {