From 01103b26f02fc07445969f7d88358b7c9ced5091 Mon Sep 17 00:00:00 2001 From: Seebs Date: Mon, 21 Jun 2021 11:12:09 -0500 Subject: [PATCH] make etcd bootstrap timeout configurable It turns out that it's desireable to be able to configure the bootstrap timeout for etcd, because during startup, we end up delaying that long (N-1) times in series during each cluster creation, which is pointless when we're starting the whole cluster. Reduces test runtime by several minutes. --- etcd/embed.go | 3 +++ go.mod | 2 +- go.sum | 4 ++-- test/disco.go | 18 ++++++++++-------- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/etcd/embed.go b/etcd/embed.go index 3f3ec75a5..25800c4de 100644 --- a/etcd/embed.go +++ b/etcd/embed.go @@ -61,6 +61,8 @@ type Options struct { LPeerSocket []*net.TCPListener LClientSocket []*net.TCPListener + + BootstrapTimeout time.Duration } var ( @@ -224,6 +226,7 @@ func parseOptions(opt Options) *embed.Config { cfg.Name = opt.Name cfg.Dir = opt.Dir cfg.InitialClusterToken = opt.ClusterName + cfg.BootstrapTimeout = opt.BootstrapTimeout cfg.LCUrls = types.MustNewURLs([]string{opt.LClientURL}) if opt.AClientURL != "" { cfg.ACUrls = types.MustNewURLs([]string{opt.AClientURL}) diff --git a/go.mod b/go.mod index 7af634a50..3eb1fdbe6 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/pilosa/pilosa/v2 -replace go.etcd.io/etcd => github.com/molecula/etcd v0.0.0-20210115113447-5d28bda617d2 +replace go.etcd.io/etcd => github.com/molecula/etcd v0.0.0-20210621160528-2cd93f1df0e7 require ( github.com/CAFxX/gcnotifier v0.0.0-20190112062741-224a280d589d diff --git a/go.sum b/go.sum index 296acadcb..4755dfe03 100644 --- a/go.sum +++ b/go.sum @@ -226,8 +226,8 @@ github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9 github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/molecula/apophenia v0.0.0-20190827192002-68b7a14a478b h1:cZADDaNYM7xn/nklO3g198JerGQjadFuA0ofxBJgK0Y= github.com/molecula/apophenia v0.0.0-20190827192002-68b7a14a478b/go.mod h1:uXd1BiH7xLmgkhVmspdJLENv6uGWrTL/MQX2TN7Yz9s= -github.com/molecula/etcd v0.0.0-20210115113447-5d28bda617d2 h1:pkzCVLSrFQGVQv3raVGJw6aJCJdIZC/z59tUsSU1Zws= -github.com/molecula/etcd v0.0.0-20210115113447-5d28bda617d2/go.mod h1:1X1h4BZ44WjM0LJof1gKKLap1OA4RsicGCDRtACTkLI= +github.com/molecula/etcd v0.0.0-20210621160528-2cd93f1df0e7 h1:hufElvtCighE0G2VFJYDGWCY8JlmCWZ1FmXvlf25yUQ= +github.com/molecula/etcd v0.0.0-20210621160528-2cd93f1df0e7/go.mod h1:1X1h4BZ44WjM0LJof1gKKLap1OA4RsicGCDRtACTkLI= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223 h1:F9x/1yl3T2AeKLr2AMdilSD8+f9bvMnNN8VS5iDtovc= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= diff --git a/test/disco.go b/test/disco.go index fad3783b9..ac19940d5 100644 --- a/test/disco.go +++ b/test/disco.go @@ -19,6 +19,7 @@ import ( "net" "strings" "testing" + "time" "github.com/pilosa/pilosa/v2/etcd" "github.com/pilosa/pilosa/v2/server" @@ -101,14 +102,15 @@ func GetPortsGenConfigs(tb testing.TB, nodes []*Command) error { config.BindGRPC = grpcUrl config.GRPCListener = grpcListener config.Etcd = etcd.Options{ - Dir: discoDir, - LClientURL: clientURL, - AClientURL: clientURL, - LPeerURL: peerURL, - APeerURL: peerURL, - HeartbeatTTL: 12, - LPeerSocket: []*net.TCPListener{peerListener}, - LClientSocket: []*net.TCPListener{clientListener}, + Dir: discoDir, + LClientURL: clientURL, + AClientURL: clientURL, + LPeerURL: peerURL, + APeerURL: peerURL, + HeartbeatTTL: 12, + LPeerSocket: []*net.TCPListener{peerListener}, + LClientSocket: []*net.TCPListener{clientListener}, + BootstrapTimeout: 50 * time.Millisecond, } peerUrls[i] = fmt.Sprintf("%s=%s", name, peerURL) }