From 1671efe7a8e6576633a881e8fbba500217cc2d5d Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Sun, 22 Jan 2023 14:11:21 -0500 Subject: [PATCH] Do not use a global variable for etcdURL we are saving this information in an env variable `KUBE_INTEGRATION_ETCD_URL` So just pick it up from there when needed. Currently when someone uses framework.RunCustomEtcd directly, the global variable is *not* set and the code that uses `GetEtcdURL` returns empty string. Signed-off-by: Davanum Srinivas --- test/integration/framework/etcd.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/test/integration/framework/etcd.go b/test/integration/framework/etcd.go index 966f6538394..4f6e2115d70 100644 --- a/test/integration/framework/etcd.go +++ b/test/integration/framework/etcd.go @@ -36,8 +36,6 @@ import ( "k8s.io/kubernetes/pkg/util/env" ) -var etcdURL = "" - const installEtcd = ` Cannot find etcd, cannot run integration tests Please see https://git.k8s.io/community/contributors/devel/sig-testing/integration-tests.md#install-etcd-dependency for instructions. @@ -70,7 +68,7 @@ func startEtcd() (func(), error) { os.Setenv("ETCD_UNSUPPORTED_ARCH", "arm64") } - etcdURL = env.GetEnvAsStringOrFallback("KUBE_INTEGRATION_ETCD_URL", "http://127.0.0.1:2379") + etcdURL := env.GetEnvAsStringOrFallback("KUBE_INTEGRATION_ETCD_URL", "http://127.0.0.1:2379") conn, err := net.Dial("tcp", strings.TrimPrefix(etcdURL, "http://")) if err == nil { klog.Infof("etcd already running at %s", etcdURL) @@ -84,8 +82,7 @@ func startEtcd() (func(), error) { return nil, err } - etcdURL = currentURL - os.Setenv("KUBE_INTEGRATION_ETCD_URL", etcdURL) + os.Setenv("KUBE_INTEGRATION_ETCD_URL", currentURL) return stop, nil } @@ -221,5 +218,5 @@ func EtcdMain(tests func() int) { // GetEtcdURL returns the URL of the etcd instance started by EtcdMain. func GetEtcdURL() string { - return etcdURL + return env.GetEnvAsStringOrFallback("KUBE_INTEGRATION_ETCD_URL", "http://127.0.0.1:2379") }