Skip to content

Commit

Permalink
Upgrade etcd to v3.4.26
Browse files Browse the repository at this point in the history
Signed-off-by: JmPotato <[email protected]>
  • Loading branch information
JmPotato committed Mar 6, 2024
1 parent e72d49b commit 100f01f
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 129 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ require (
github.com/syndtr/goleveldb v1.0.1-0.20190318030020-c3a204f8e965
github.com/unrolled/render v1.0.1
github.com/urfave/negroni v0.3.0
go.etcd.io/etcd v0.5.0-alpha.5.0.20220915004622-85b640cee793
go.etcd.io/etcd v0.5.0-alpha.5.0.20230512014047-a603c0798948
go.uber.org/atomic v1.10.0
go.uber.org/goleak v1.2.0
go.uber.org/zap v1.26.0
Expand Down Expand Up @@ -173,7 +173,7 @@ require (
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
// Fix panic in unit test with go >= 1.14, ref: etcd-io/bbolt#201 https://github.com/etcd-io/bbolt/pull/201
go.etcd.io/bbolt v1.3.6 // indirect
go.etcd.io/bbolt v1.3.7 // indirect
go.uber.org/dig v1.9.0 // indirect
go.uber.org/fx v1.12.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
Expand Down
36 changes: 4 additions & 32 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/dashboard/adapter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func GenDashboardConfig(srv *server.Server) (*config.Config, error) {

dashboardCfg := config.Default()
dashboardCfg.DataDir = cfg.DataDir
dashboardCfg.PDEndPoint = etcdCfg.ACUrls[0].String()
dashboardCfg.PDEndPoint = etcdCfg.AdvertiseClientUrls[0].String()
dashboardCfg.PublicPathPrefix = cfg.Dashboard.PublicPathPrefix
dashboardCfg.EnableTelemetry = cfg.Dashboard.EnableTelemetry
dashboardCfg.EnableExperimental = cfg.Dashboard.EnableExperimental
Expand Down
6 changes: 3 additions & 3 deletions pkg/election/leadership_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func TestExitWatch(t *testing.T) {
checkExitWatch(t, leaderKey, func(server *embed.Etcd, client *clientv3.Client) func() {
cfg1 := server.Config()
etcd2 := etcdutil.MustAddEtcdMember(t, &cfg1, client)
client2, err := etcdutil.CreateEtcdClient(nil, etcd2.Config().LCUrls)
client2, err := etcdutil.CreateEtcdClient(nil, etcd2.Config().ListenClientUrls)
re.NoError(err)
// close the original leader
server.Server.HardStop()
Expand Down Expand Up @@ -189,7 +189,7 @@ func checkExitWatch(t *testing.T, leaderKey string, injectFunc func(server *embe
re := require.New(t)
servers, client1, clean := etcdutil.NewTestEtcdCluster(t, 1)
defer clean()
client2, err := etcdutil.CreateEtcdClient(nil, servers[0].Config().LCUrls)
client2, err := etcdutil.CreateEtcdClient(nil, servers[0].Config().ListenClientUrls)
re.NoError(err)
defer client2.Close()

Expand Down Expand Up @@ -225,7 +225,7 @@ func TestRequestProgress(t *testing.T) {
defer os.RemoveAll(fname)
servers, client1, clean := etcdutil.NewTestEtcdCluster(t, 1)
defer clean()
client2, err := etcdutil.CreateEtcdClient(nil, servers[0].Config().LCUrls)
client2, err := etcdutil.CreateEtcdClient(nil, servers[0].Config().ListenClientUrls)
re.NoError(err)
defer client2.Close()

Expand Down
2 changes: 1 addition & 1 deletion pkg/mcs/scheduling/server/rule/watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func prepare(t require.TestingT) (context.Context, *clientv3.Client, func()) {
os.RemoveAll(cfg.Dir)
etcd, err := embed.StartEtcd(cfg)
re.NoError(err)
client, err := etcdutil.CreateEtcdClient(nil, cfg.LCUrls)
client, err := etcdutil.CreateEtcdClient(nil, cfg.ListenClientUrls)
re.NoError(err)
<-etcd.Server.ReadyNotify()

Expand Down
2 changes: 1 addition & 1 deletion pkg/tso/keyspace_group_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (suite *keyspaceGroupManagerTestSuite) SetupSuite() {
suite.ctx, suite.cancel = context.WithCancel(context.Background())
suite.ClusterID = rand.Uint64()
servers, client, clean := etcdutil.NewTestEtcdCluster(t, 1)
suite.backendEndpoints, suite.etcdClient, suite.clean = servers[0].Config().LCUrls[0].String(), client, clean
suite.backendEndpoints, suite.etcdClient, suite.clean = servers[0].Config().ListenClientUrls[0].String(), client, clean
suite.cfg = suite.createConfig()
}

Expand Down
14 changes: 7 additions & 7 deletions pkg/utils/etcdutil/etcdutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ func TestEtcdScaleInAndOut(t *testing.T) {
etcd1, cfg1 := servers[0], servers[0].Config()

// Create two etcd clients with etcd1 as endpoint.
client1, err := CreateEtcdClient(nil, cfg1.LCUrls) // execute member change operation with this client
client1, err := CreateEtcdClient(nil, cfg1.ListenClientUrls) // execute member change operation with this client
re.NoError(err)
defer client1.Close()
client2, err := CreateEtcdClient(nil, cfg1.LCUrls) // check member change with this client
client2, err := CreateEtcdClient(nil, cfg1.ListenClientUrls) // check member change with this client
re.NoError(err)
defer client2.Close()

Expand Down Expand Up @@ -287,7 +287,7 @@ func checkEtcdWithHangLeader(t *testing.T) error {
var enableDiscard atomic.Bool
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
go proxyWithDiscard(ctx, re, cfg1.LCUrls[0].String(), proxyAddr, &enableDiscard)
go proxyWithDiscard(ctx, re, cfg1.ListenClientUrls[0].String(), proxyAddr, &enableDiscard)

// Create an etcd client with etcd1 as endpoint.
urls, err := types.NewURLs([]string{proxyAddr})
Expand Down Expand Up @@ -409,7 +409,7 @@ func (suite *loopWatcherTestSuite) SetupSuite() {
suite.config = NewTestSingleConfig()
suite.config.Dir = suite.T().TempDir()
suite.startEtcd(re)
suite.client, err = CreateEtcdClient(nil, suite.config.LCUrls)
suite.client, err = CreateEtcdClient(nil, suite.config.ListenClientUrls)
re.NoError(err)
suite.cleans = append(suite.cleans, func() {
suite.client.Close()
Expand Down Expand Up @@ -668,23 +668,23 @@ func (suite *loopWatcherTestSuite) TestWatcherBreak() {

// Case2: close the etcd client and put a new value after watcher restarts
suite.client.Close()
suite.client, err = CreateEtcdClient(nil, suite.config.LCUrls)
suite.client, err = CreateEtcdClient(nil, suite.config.ListenClientUrls)
re.NoError(err)
watcher.updateClientCh <- suite.client
suite.put(re, "TestWatcherBreak", "2")
checkCache("2")

// Case3: close the etcd client and put a new value before watcher restarts
suite.client.Close()
suite.client, err = CreateEtcdClient(nil, suite.config.LCUrls)
suite.client, err = CreateEtcdClient(nil, suite.config.ListenClientUrls)
re.NoError(err)
suite.put(re, "TestWatcherBreak", "3")
watcher.updateClientCh <- suite.client
checkCache("3")

// Case4: close the etcd client and put a new value with compact
suite.client.Close()
suite.client, err = CreateEtcdClient(nil, suite.config.LCUrls)
suite.client, err = CreateEtcdClient(nil, suite.config.ListenClientUrls)
re.NoError(err)
suite.put(re, "TestWatcherBreak", "4")
resp, err := EtcdKVGet(suite.client, "TestWatcherBreak")
Expand Down
16 changes: 8 additions & 8 deletions pkg/utils/etcdutil/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ func NewTestSingleConfig() *embed.Config {
cfg.LogOutputs = []string{"stdout"}

pu, _ := url.Parse(tempurl.Alloc())
cfg.LPUrls = []url.URL{*pu}
cfg.APUrls = cfg.LPUrls
cfg.ListenPeerUrls = []url.URL{*pu}
cfg.AdvertisePeerUrls = cfg.ListenPeerUrls
cu, _ := url.Parse(tempurl.Alloc())
cfg.LCUrls = []url.URL{*cu}
cfg.ACUrls = cfg.LCUrls
cfg.ListenClientUrls = []url.URL{*cu}
cfg.AdvertiseClientUrls = cfg.ListenClientUrls

cfg.StrictReconfigCheck = false
cfg.InitialCluster = fmt.Sprintf("%s=%s", cfg.Name, &cfg.LPUrls[0])
cfg.InitialCluster = fmt.Sprintf("%s=%s", cfg.Name, &cfg.ListenPeerUrls[0])
cfg.ClusterState = embed.ClusterStateFlagNew
return cfg
}
Expand All @@ -63,7 +63,7 @@ func NewTestEtcdCluster(t *testing.T, count int) (servers []*embed.Etcd, etcdCli
cfg.Dir = t.TempDir()
etcd, err := embed.StartEtcd(cfg)
re.NoError(err)
etcdClient, err = CreateEtcdClient(nil, cfg.LCUrls)
etcdClient, err = CreateEtcdClient(nil, cfg.ListenClientUrls)
re.NoError(err)
<-etcd.Server.ReadyNotify()
servers = append(servers, etcd)
Expand Down Expand Up @@ -101,9 +101,9 @@ func MustAddEtcdMember(t *testing.T, cfg1 *embed.Config, client *clientv3.Client
cfg2 := NewTestSingleConfig()
cfg2.Dir = t.TempDir()
cfg2.Name = genRandName()
cfg2.InitialCluster = cfg1.InitialCluster + fmt.Sprintf(",%s=%s", cfg2.Name, &cfg2.LPUrls[0])
cfg2.InitialCluster = cfg1.InitialCluster + fmt.Sprintf(",%s=%s", cfg2.Name, &cfg2.ListenPeerUrls[0])
cfg2.ClusterState = embed.ClusterStateFlagExisting
peerURL := cfg2.LPUrls[0].String()
peerURL := cfg2.ListenPeerUrls[0].String()
addResp, err := AddEtcdMember(client, []string{peerURL})
re.NoError(err)
// Check the client can get the new member.
Expand Down
8 changes: 4 additions & 4 deletions server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -748,22 +748,22 @@ func (c *Config) GenEmbedEtcdConfig() (*embed.Config, error) {
cfg.Logger = "zap"
var err error

cfg.LPUrls, err = parseUrls(c.PeerUrls)
cfg.ListenPeerUrls, err = parseUrls(c.PeerUrls)
if err != nil {
return nil, err
}

cfg.APUrls, err = parseUrls(c.AdvertisePeerUrls)
cfg.AdvertisePeerUrls, err = parseUrls(c.AdvertisePeerUrls)
if err != nil {
return nil, err
}

cfg.LCUrls, err = parseUrls(c.ClientUrls)
cfg.ListenClientUrls, err = parseUrls(c.ClientUrls)
if err != nil {
return nil, err
}

cfg.ACUrls, err = parseUrls(c.AdvertiseClientUrls)
cfg.AdvertiseClientUrls, err = parseUrls(c.AdvertiseClientUrls)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,12 @@ func (s *Server) startClient() error {
}
/* Starting two different etcd clients here is to avoid the throttling. */
// This etcd client will be used to access the etcd cluster to read and write all kinds of meta data.
s.client, err = etcdutil.CreateEtcdClient(tlsConfig, etcdCfg.ACUrls, "server-etcd-client")
s.client, err = etcdutil.CreateEtcdClient(tlsConfig, etcdCfg.AdvertiseClientUrls, "server-etcd-client")
if err != nil {
return errs.ErrNewEtcdClient.Wrap(err).GenWithStackByCause()
}
// This etcd client will only be used to read and write the election-related data, such as leader key.
s.electionClient, err = etcdutil.CreateEtcdClient(tlsConfig, etcdCfg.ACUrls, "election-etcd-client")
s.electionClient, err = etcdutil.CreateEtcdClient(tlsConfig, etcdCfg.AdvertiseClientUrls, "election-etcd-client")
if err != nil {
return errs.ErrNewEtcdClient.Wrap(err).GenWithStackByCause()
}
Expand Down
4 changes: 2 additions & 2 deletions tests/integrations/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
github.com/stretchr/testify v1.8.4
github.com/tikv/pd v0.0.0-00010101000000-000000000000
github.com/tikv/pd/client v0.0.0-00010101000000-000000000000
go.etcd.io/etcd v0.5.0-alpha.5.0.20220915004622-85b640cee793
go.etcd.io/etcd v0.5.0-alpha.5.0.20230512014047-a603c0798948
go.uber.org/goleak v1.3.0
go.uber.org/zap v1.26.0
google.golang.org/grpc v1.59.0
Expand Down Expand Up @@ -163,7 +163,7 @@ require (
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.etcd.io/bbolt v1.3.6 // indirect
go.etcd.io/bbolt v1.3.7 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/dig v1.9.0 // indirect
go.uber.org/fx v1.12.0 // indirect
Expand Down
Loading

0 comments on commit 100f01f

Please sign in to comment.