Merge pull request #51633 from deads2k/controller-03-wait

Automatic merge from submit-queue (batch tested with PRs 51707, 51662, 51723, 50163, 51633)

update GC controller to wait until controllers have been initialized …

fixes #51013

Alternative to https://github.com/kubernetes/kubernetes/pull/51492 which keeps those few controllers (only one) from starting the informers early.
This commit is contained in:
Kubernetes Submit Queue
2017-08-31 18:43:41 -07:00
committed by GitHub
6 changed files with 30 additions and 3 deletions

View File

@@ -157,6 +157,7 @@ func Run(s *options.CMServer) error {
}
ctx.InformerFactory.Start(ctx.Stop)
close(ctx.InformersStarted)
select {}
}
@@ -264,6 +265,10 @@ type ControllerContext struct {
// Stop is the stop channel
Stop <-chan struct{}
// InformersStarted is closed after all of the controllers have been initialized and are running. After this point it is safe,
// for an individual controller to start the shared informers. Before it is closed, they should not.
InformersStarted chan struct{}
}
func (c ControllerContext) IsControllerEnabled(name string) bool {
@@ -443,6 +448,7 @@ func CreateControllerContext(s *options.CMServer, rootClientBuilder, clientBuild
AvailableResources: availableResources,
Cloud: cloud,
Stop: stop,
InformersStarted: make(chan struct{}),
}
return ctx, nil
}

View File

@@ -330,6 +330,7 @@ func startGarbageCollectorController(ctx ControllerContext) (bool, error) {
deletableResources,
ignoredResources,
ctx.InformerFactory,
ctx.InformersStarted,
)
if err != nil {
return true, fmt.Errorf("Failed to start the generic garbage collector: %v", err)