From 4eb3a48862ff3b0681c92dac3a64e84bb0c88b33 Mon Sep 17 00:00:00 2001 From: Brad Davidson Date: Tue, 29 Mar 2022 11:45:21 -0700 Subject: [PATCH] Skip setting up client tls when etcd server does not have tls enabled Signed-off-by: Brad Davidson --- pkg/etcd/etcd.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/etcd/etcd.go b/pkg/etcd/etcd.go index 4c61e5b9e878..1398991184a6 100644 --- a/pkg/etcd/etcd.go +++ b/pkg/etcd/etcd.go @@ -608,18 +608,20 @@ func getClientConfig(ctx context.Context, runtime *config.ControlRuntime, endpoi if len(endpoints) == 0 { endpoints = getEndpoints(runtime) } - tlsConfig, err := toTLSConfig(runtime) - if err != nil { - return nil, err - } - return &etcd.Config{ + + config := &etcd.Config{ Endpoints: endpoints, - TLS: tlsConfig, Context: ctx, DialTimeout: defaultDialTimeout, DialKeepAliveTime: defaultKeepAliveTime, DialKeepAliveTimeout: defaultKeepAliveTimeout, - }, nil + } + + var err error + if strings.HasPrefix(endpoints[0], "https://") { + config.TLS, err = toTLSConfig(runtime) + } + return config, err } // getEndpoints returns the endpoints from the runtime config if set, otherwise the default endpoint.