Clean shutdown of kcm, ccm and scheduler
This commit is contained in:
@@ -41,6 +41,7 @@ import (
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
cacheddiscovery "k8s.io/client-go/discovery/cached"
|
||||
"k8s.io/client-go/informers"
|
||||
v1core "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
"k8s.io/client-go/metadata"
|
||||
"k8s.io/client-go/metadata/metadatainformer"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
@@ -174,13 +175,18 @@ func ResyncPeriod(c *config.CompletedConfig) func() time.Duration {
|
||||
}
|
||||
}
|
||||
|
||||
// Run runs the KubeControllerManagerOptions. This should never exit.
|
||||
// Run runs the KubeControllerManagerOptions.
|
||||
func Run(c *config.CompletedConfig, stopCh <-chan struct{}) error {
|
||||
// To help debugging, immediately log version
|
||||
klog.Infof("Version: %+v", version.Get())
|
||||
|
||||
klog.InfoS("Golang settings", "GOGC", os.Getenv("GOGC"), "GOMAXPROCS", os.Getenv("GOMAXPROCS"), "GOTRACEBACK", os.Getenv("GOTRACEBACK"))
|
||||
|
||||
// Start events processing pipeline.
|
||||
c.EventBroadcaster.StartStructuredLogging(0)
|
||||
c.EventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: c.Client.CoreV1().Events("")})
|
||||
defer c.EventBroadcaster.Shutdown()
|
||||
|
||||
if cfgz, err := configz.New(ConfigzName); err == nil {
|
||||
cfgz.Set(c.ComponentConfig)
|
||||
} else {
|
||||
@@ -213,7 +219,6 @@ func Run(c *config.CompletedConfig, stopCh <-chan struct{}) error {
|
||||
saTokenControllerInitFunc := serviceAccountTokenControllerStarter{rootClientBuilder: rootClientBuilder}.startServiceAccountTokenController
|
||||
|
||||
run := func(ctx context.Context, startSATokenController InitFunc, initializersFunc ControllerInitializersFunc) {
|
||||
|
||||
controllerContext, err := CreateControllerContext(c, rootClientBuilder, clientBuilder, ctx.Done())
|
||||
if err != nil {
|
||||
klog.Fatalf("error building controller context: %v", err)
|
||||
@@ -227,13 +232,14 @@ func Run(c *config.CompletedConfig, stopCh <-chan struct{}) error {
|
||||
controllerContext.ObjectOrMetadataInformerFactory.Start(stopCh)
|
||||
close(controllerContext.InformersStarted)
|
||||
|
||||
select {}
|
||||
<-ctx.Done()
|
||||
}
|
||||
|
||||
// No leader election, run directly
|
||||
if !c.ComponentConfig.Generic.LeaderElection.LeaderElect {
|
||||
run(context.TODO(), saTokenControllerInitFunc, NewControllerInitializers)
|
||||
panic("unreachable")
|
||||
ctx, _ := wait.ContextForChannel(stopCh)
|
||||
run(ctx, saTokenControllerInitFunc, NewControllerInitializers)
|
||||
return nil
|
||||
}
|
||||
|
||||
id, err := os.Hostname()
|
||||
@@ -311,7 +317,8 @@ func Run(c *config.CompletedConfig, stopCh <-chan struct{}) error {
|
||||
})
|
||||
}
|
||||
|
||||
select {}
|
||||
<-stopCh
|
||||
return nil
|
||||
}
|
||||
|
||||
// ControllerContext defines the context object for controller
|
||||
|
Reference in New Issue
Block a user