Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: upgrade etcd to master #1101

Merged
merged 9 commits into from
Jun 7, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
61 changes: 44 additions & 17 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

[[constraint]]
name = "github.com/coreos/etcd"
version = "=3.3.4"
branch = "master"

[[override]]
name = "github.com/coreos/bbolt"
version = "=v1.3.1-coreos.6"

[[override]]
name = "github.com/grpc-ecosystem/grpc-gateway"
version = "~1.3"
version = "~1.4"

[[constraint]]
name = "google.golang.org/grpc"
Expand Down
2 changes: 1 addition & 1 deletion pd-client/leader_change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ func (s *testLeaderChangeSuite) prepareClusterN(c *C, n int) (svrs map[string]*s

for i := 0; i < n; i++ {
cfg := cfgs[i]

go func() {
svr, err := server.CreateServer(cfg, api.NewHandler)
c.Assert(err, IsNil)
svr.SetUpTestMode()
err = svr.Run()
c.Assert(err, IsNil)
ch <- svr
Expand Down
2 changes: 1 addition & 1 deletion pkg/etcdutil/etcdutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func CheckClusterID(localClusterID types.ID, um types.URLsMap, tlsConfig *tls.Co
trp := &http.Transport{
TLSClientConfig: tlsConfig,
}
remoteCluster, gerr := etcdserver.GetClusterFromRemotePeers([]string{u}, trp)
remoteCluster, gerr := etcdserver.GetClusterFromRemotePeers(nil, []string{u}, trp)
trp.CloseIdleConnections()
if gerr != nil {
// Do not return error, because other members may be not ready.
Expand Down
2 changes: 2 additions & 0 deletions pkg/etcdutil/etcdutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ func newTestSingleConfig() *embed.Config {
cfg.Name = "test_etcd"
cfg.Dir, _ = ioutil.TempDir("/tmp", "test_etcd")
cfg.WalDir = ""
cfg.Logger = "zap"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we use zap in production?

Copy link
Contributor Author

@nolouch nolouch Jun 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

etcd plan to use zap replace the capnslog logging. and we only enable it in the test.

cfg.LogOutputs = []string{"stdout"}

pu, _ := url.Parse(tempurl.Alloc())
cfg.LPUrls = []url.URL{*pu}
Expand Down
1 change: 1 addition & 0 deletions server/api/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func mustNewCluster(c *C, num int) ([]*server.Config, []*server.Server, cleanUpF
go func(cfg *server.Config) {
s, err := server.CreateServer(cfg, NewHandler)
c.Assert(err, IsNil)
s.SetUpTestMode()
err = s.Run()
c.Assert(err, IsNil)
ch <- s
Expand Down
9 changes: 5 additions & 4 deletions server/api/store_ns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ func (s *testStoreNsSuite) SetUpSuite(c *C) {

cfg := server.NewTestSingleConfig()
cfg.NamespaceClassifier = "table"
srv, err := server.CreateServer(cfg, NewHandler)
svr, err := server.CreateServer(cfg, NewHandler)
c.Assert(err, IsNil)
c.Assert(srv.Run(), IsNil)
s.svr = srv
svr.SetUpTestMode()
c.Assert(svr.Run(), IsNil)
s.svr = svr
s.cleanup = func() {
srv.Close()
svr.Close()
cleanServer(cfg)
}

Expand Down
4 changes: 3 additions & 1 deletion server/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ func PrepareJoinCluster(cfg *Config) error {
}

// Cases with data directory.
// The path change from "member" to "member/wal"
// Reference: https://github.com/coreos/etcd/pull/9733
initialCluster := ""
if wal.Exist(path.Join(cfg.DataDir, "member")) {
if wal.Exist(path.Join(cfg.DataDir, "member/wal")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, it breaks the compatibility?

Copy link
Contributor Author

@nolouch nolouch Jun 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, it's compatibility. but better to keep the previous logic. address it.

cfg.InitialCluster = initialCluster
cfg.InitialClusterState = embed.ClusterStateFlagExisting
return nil
Expand Down
1 change: 1 addition & 0 deletions server/join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func startPdWith(cfg *Config) (*Server, error) {
errCh <- errors.Trace(err)
return
}
svr.SetUpTestMode()
err = svr.Run()
if err != nil {
errCh <- errors.Trace(err)
Expand Down
9 changes: 4 additions & 5 deletions server/leader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,15 @@ type testGetLeaderSuite struct {
func (s *testGetLeaderSuite) SetUpSuite(c *C) {
cfg := NewTestSingleConfig()

// Send requests before server has started.
s.wg.Add(1)
s.done = make(chan bool)
go s.sendRequest(c, cfg.ClientUrls)
time.Sleep(100 * time.Millisecond)

svr, err := CreateServer(cfg, nil)
c.Assert(err, IsNil)

svr.SetUpTestMode()
err = svr.Run()
// Send requests after server has started.
go s.sendRequest(c, cfg.ClientUrls)
time.Sleep(100 * time.Millisecond)
c.Assert(err, IsNil)

s.svr = svr
Expand Down
10 changes: 10 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,16 @@ func (s *Server) Run() error {
return nil
}

// SetUpTestMode for testing
func (s *Server) SetUpTestMode() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do it in server.CreateServer? It looks verbose to call it in every tests...

// The etcd master version has removed embed.Config.SetupLogging.
// Now logger is set up automatically based on embed.Config.Logger, embed.Config.LogOutputs, embed.Config.Debug fields.
// Use zap logger in the test, otherwise will panic. Reference: https://github.com/coreos/etcd/blob/master/embed/config_logging.go#L45
s.etcdCfg.Logger = "zap"
s.etcdCfg.LogOutputs = []string{"stdout"}
s.etcdCfg.Debug = false
}

func (s *Server) bootstrapCluster(req *pdpb.BootstrapRequest) (*pdpb.BootstrapResponse, error) {
clusterID := s.clusterID

Expand Down
4 changes: 4 additions & 0 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func newTestServer(c *C) (*Server, cleanUpFunc) {

svr, err := CreateServer(cfg, nil)
c.Assert(err, IsNil)
svr.SetUpTestMode()

cleanup := func() {
svr.Close()
Expand Down Expand Up @@ -94,6 +95,7 @@ func (s *testLeaderServerSuite) SetUpSuite(c *C) {
go func() {
svr, err := CreateServer(cfg, nil)
c.Assert(err, IsNil)
svr.SetUpTestMode()
err = svr.Run()
c.Assert(err, IsNil)
ch <- svr
Expand Down Expand Up @@ -149,6 +151,7 @@ func newTestServersWithCfgs(c *C, cfgs []*Config) ([]*Server, cleanupFunc) {
go func(cfg *Config) {
svr, err := CreateServer(cfg, nil)
c.Assert(err, IsNil)
svr.SetUpTestMode()
err = svr.Run()
c.Assert(err, IsNil)
ch <- svr
Expand Down Expand Up @@ -268,6 +271,7 @@ func (s *testServerSuite) TestCheckClusterID(c *C) {
cfgA.InitialCluster = originInitial
svr, err := CreateServer(cfgA, nil)
c.Assert(err, IsNil)
svr.SetUpTestMode()
err = svr.Run()
c.Assert(err, NotNil)
}
1 change: 1 addition & 0 deletions server/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func NewTestServer() (*Config, *Server, CleanupFunc, error) {
if err != nil {
return nil, nil, nil, errors.Trace(err)
}
s.SetUpTestMode()
if err = s.Run(); err != nil {
return nil, nil, nil, errors.Trace(err)
}
Expand Down
14 changes: 0 additions & 14 deletions vendor/github.com/BurntSushi/toml/COPYING

This file was deleted.

14 changes: 0 additions & 14 deletions vendor/github.com/BurntSushi/toml/cmd/toml-test-decoder/COPYING

This file was deleted.

14 changes: 0 additions & 14 deletions vendor/github.com/BurntSushi/toml/cmd/toml-test-encoder/COPYING

This file was deleted.

14 changes: 0 additions & 14 deletions vendor/github.com/BurntSushi/toml/cmd/tomlv/COPYING

This file was deleted.

1 change: 0 additions & 1 deletion vendor/github.com/coreos/etcd/Documentation/README.md

This file was deleted.

5 changes: 0 additions & 5 deletions vendor/github.com/coreos/etcd/NOTICE

This file was deleted.

Loading