mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Merge pull request #78144 from lubinsz/pr_bazel_etcdmaster
Bug fix: remove etcd related issues in bazel-test-integration
This commit is contained in:
commit
bab3634adf
@ -26,6 +26,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/coreos/etcd/clientv3"
|
"github.com/coreos/etcd/clientv3"
|
||||||
"google.golang.org/grpc/grpclog"
|
"google.golang.org/grpc/grpclog"
|
||||||
@ -94,6 +95,7 @@ func startEtcd() (func(), error) {
|
|||||||
return nil, fmt.Errorf("could not get a port: %v", err)
|
return nil, fmt.Errorf("could not get a port: %v", err)
|
||||||
}
|
}
|
||||||
etcdURL = fmt.Sprintf("http://127.0.0.1:%d", etcdPort)
|
etcdURL = fmt.Sprintf("http://127.0.0.1:%d", etcdPort)
|
||||||
|
|
||||||
klog.Infof("starting etcd on %s", etcdURL)
|
klog.Infof("starting etcd on %s", etcdURL)
|
||||||
|
|
||||||
etcdDataDir, err := ioutil.TempDir(os.TempDir(), "integration_test_etcd_data")
|
etcdDataDir, err := ioutil.TempDir(os.TempDir(), "integration_test_etcd_data")
|
||||||
@ -136,6 +138,28 @@ func startEtcd() (func(), error) {
|
|||||||
if err := cmd.Start(); err != nil {
|
if err := cmd.Start(); err != nil {
|
||||||
return nil, fmt.Errorf("failed to run etcd: %v", err)
|
return nil, fmt.Errorf("failed to run etcd: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var i int32 = 1
|
||||||
|
const pollCount = int32(300)
|
||||||
|
|
||||||
|
for i <= pollCount {
|
||||||
|
conn, err = net.DialTimeout("tcp", strings.TrimPrefix(etcdURL, "http://"), 1*time.Second)
|
||||||
|
if err == nil {
|
||||||
|
conn.Close()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if i == pollCount {
|
||||||
|
stop()
|
||||||
|
return nil, fmt.Errorf("could not start etcd")
|
||||||
|
}
|
||||||
|
|
||||||
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
i = i + 1
|
||||||
|
}
|
||||||
|
|
||||||
|
os.Setenv("KUBE_INTEGRATION_ETCD_URL", etcdURL)
|
||||||
|
|
||||||
return stop, nil
|
return stop, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user