From 88e668cf6f683da1b6405994f45317147dd50fc0 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 30 Jul 2019 10:03:39 +0900 Subject: [PATCH] Simplify startWrangler a bit We no longer make dynamiclistener generate CA certs. --- pkg/server/server.go | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/pkg/server/server.go b/pkg/server/server.go index 7c9be7d208..0d94adde5a 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -11,7 +11,6 @@ import ( "path/filepath" "strconv" "strings" - "time" "github.com/pkg/errors" "github.com/rancher/dynamiclistener" @@ -72,7 +71,6 @@ func StartServer(ctx context.Context, config *Config) (string, error) { func startWrangler(ctx context.Context, config *Config) (string, error) { var ( err error - tlsServer dynamiclistener.ServerInterface tlsConfig = &config.TLSConfig controlConfig = &config.ControlConfig ) @@ -86,14 +84,12 @@ func startWrangler(ctx context.Context, config *Config) (string, error) { return "", err } - tlsConfig.CACerts = string(caBytes) + certs := string(caBytes) + tlsConfig.CACerts = certs tlsConfig.CAKey = string(caKeyBytes) tlsConfig.Handler = router(controlConfig, controlConfig.Runtime.Tunnel, func() (string, error) { - if tlsServer == nil { - return "", nil - } - return tlsServer.CACert() + return certs, nil }) sc, err := newContext(ctx, controlConfig.Runtime.KubeConfigAdmin) @@ -105,7 +101,7 @@ func startWrangler(ctx context.Context, config *Config) (string, error) { return "", err } - tlsServer, err = tls.NewServer(ctx, sc.K3s.K3s().V1().ListenerConfig(), *tlsConfig) + _, err = tls.NewServer(ctx, sc.K3s.K3s().V1().ListenerConfig(), *tlsConfig) if err != nil { return "", err } @@ -114,16 +110,6 @@ func startWrangler(ctx context.Context, config *Config) (string, error) { return "", err } - certs := "" - for certs == "" { - certs, err = tlsServer.CACert() - if err != nil { - logrus.Infof("waiting to generate CA certs") - time.Sleep(time.Second) - continue - } - } - go leader.RunOrDie(ctx, "", "k3s", sc.K8s, func(ctx context.Context) { if err := masterControllers(ctx, sc, config); err != nil { panic(err)