Skip to content

Commit

Permalink
Upgrade etcd to v3.4.30
Browse files Browse the repository at this point in the history
Signed-off-by: JmPotato <[email protected]>
  • Loading branch information
JmPotato committed Sep 18, 2024
1 parent a2f526d commit 2386ba1
Show file tree
Hide file tree
Showing 14 changed files with 3,350 additions and 149 deletions.
21 changes: 9 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ require (
github.com/gin-gonic/gin v1.7.4
github.com/go-echarts/go-echarts v1.0.0
github.com/gogo/protobuf v1.3.2
github.com/golang/protobuf v1.3.4
github.com/golang/protobuf v1.5.3
github.com/google/btree v1.0.0
github.com/gorilla/mux v1.7.4
github.com/gorilla/websocket v1.4.1 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/joho/godotenv v1.4.0
github.com/mattn/go-shellwords v1.0.12
Expand All @@ -33,26 +32,24 @@ require (
github.com/pingcap/log v0.0.0-20210906054005-afc726e70354
github.com/pingcap/sysutil v0.0.0-20211208032423-041a72e5860d
github.com/pingcap/tidb-dashboard v0.0.0-20220518164040-4d621864a9a0
github.com/prometheus/client_golang v1.1.0
github.com/prometheus/common v0.6.0
github.com/prometheus/client_golang v1.11.1
github.com/prometheus/common v0.26.0
github.com/sasha-s/go-deadlock v0.2.0
github.com/spf13/cobra v1.0.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.8.3
github.com/swaggo/http-swagger v0.0.0-20200308142732-58ac5e232fba
github.com/swaggo/swag v1.8.3
github.com/syndtr/goleveldb v1.0.1-0.20190318030020-c3a204f8e965
github.com/tidwall/gjson v1.9.3 // indirect
github.com/unrolled/render v1.0.1
github.com/urfave/negroni v0.3.0
// 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.5 // indirect
go.etcd.io/etcd v0.5.0-alpha.5.0.20191023171146-3cf2f69b5738
go.etcd.io/etcd v0.5.0-alpha.5.0.20240131130919-ff2304879e1b
go.uber.org/goleak v1.1.12
go.uber.org/zap v1.19.1
golang.org/x/text v0.3.7
golang.org/x/time v0.0.0-20220224211638-0e9765cccd65
golang.org/x/tools v0.1.10
google.golang.org/grpc v1.26.0
golang.org/x/text v0.14.0
golang.org/x/time v0.3.0
golang.org/x/tools v0.10.0
google.golang.org/grpc v1.58.3
gotest.tools/gotestsum v1.7.0
)
1,733 changes: 1,682 additions & 51 deletions go.sum

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions pkg/autoscaling/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"time"

. "github.com/pingcap/check"
promClient "github.com/prometheus/client_golang/api"
)

const (
Expand Down Expand Up @@ -176,7 +175,7 @@ func (c *normalClient) URL(ep string, args map[string]string) *url.URL {
return doURL(ep, args)
}

func (c *normalClient) Do(_ context.Context, req *http.Request) (response *http.Response, body []byte, warnings promClient.Warnings, err error) {
func (c *normalClient) Do(_ context.Context, req *http.Request) (response *http.Response, body []byte, err error) {
req.ParseForm()
query := req.Form.Get("query")
response, body, err = makeJSONResponse(c.mockData[query])
Expand Down Expand Up @@ -213,7 +212,7 @@ func (c *emptyResponseClient) URL(ep string, args map[string]string) *url.URL {
return doURL(ep, args)
}

func (c *emptyResponseClient) Do(_ context.Context, req *http.Request) (r *http.Response, body []byte, warnings promClient.Warnings, err error) {
func (c *emptyResponseClient) Do(_ context.Context, req *http.Request) (r *http.Response, body []byte, err error) {
promResp := &response{
Status: "success",
Data: data{
Expand Down Expand Up @@ -241,7 +240,7 @@ func (c *errorHTTPStatusClient) URL(ep string, args map[string]string) *url.URL
return doURL(ep, args)
}

func (c *errorHTTPStatusClient) Do(_ context.Context, req *http.Request) (r *http.Response, body []byte, warnings promClient.Warnings, err error) {
func (c *errorHTTPStatusClient) Do(_ context.Context, req *http.Request) (r *http.Response, body []byte, err error) {
promResp := &response{}

r, body, err = makeJSONResponse(promResp)
Expand All @@ -267,7 +266,7 @@ func (c *errorPrometheusStatusClient) URL(ep string, args map[string]string) *ur
return doURL(ep, args)
}

func (c *errorPrometheusStatusClient) Do(_ context.Context, req *http.Request) (r *http.Response, body []byte, warnings promClient.Warnings, err error) {
func (c *errorPrometheusStatusClient) Do(_ context.Context, req *http.Request) (r *http.Response, body []byte, err error) {
promResp := &response{
Status: "error",
}
Expand Down
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
10 changes: 5 additions & 5 deletions pkg/etcdutil/etcdutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,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 Down
12 changes: 6 additions & 6 deletions pkg/etcdutil/etcdutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (s *testEtcdutilSuite) TestMemberHelpers(c *C) {
}()
c.Assert(err, IsNil)

ep1 := cfg1.LCUrls[0].String()
ep1 := cfg1.ListenClientUrls[0].String()
client1, err := clientv3.New(clientv3.Config{
Endpoints: []string{ep1},
})
Expand All @@ -63,11 +63,11 @@ func (s *testEtcdutilSuite) TestMemberHelpers(c *C) {
// Make a new etcd config.
cfg2 := NewTestSingleConfig()
cfg2.Name = "etcd2"
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

// Add it to the cluster above.
peerURL := cfg2.LPUrls[0].String()
peerURL := cfg2.ListenPeerUrls[0].String()
addResp, err := AddEtcdMember(client1, []string{peerURL})
c.Assert(err, IsNil)

Expand All @@ -79,7 +79,7 @@ func (s *testEtcdutilSuite) TestMemberHelpers(c *C) {
c.Assert(err, IsNil)
c.Assert(addResp.Member.ID, Equals, uint64(etcd2.Server.ID()))

ep2 := cfg2.LCUrls[0].String()
ep2 := cfg2.ListenClientUrls[0].String()
client2, err := clientv3.New(clientv3.Config{
Endpoints: []string{ep2},
})
Expand Down Expand Up @@ -125,7 +125,7 @@ func (s *testEtcdutilSuite) TestEtcdKVGet(c *C) {
}()
c.Assert(err, IsNil)

ep := cfg.LCUrls[0].String()
ep := cfg.ListenClientUrls[0].String()
client, err := clientv3.New(clientv3.Config{
Endpoints: []string{ep},
})
Expand Down Expand Up @@ -175,7 +175,7 @@ func (s *testEtcdutilSuite) TestEtcdKVPutWithTTL(c *C) {
}()
c.Assert(err, IsNil)

ep := cfg.LCUrls[0].String()
ep := cfg.ListenClientUrls[0].String()
client, err := clientv3.New(clientv3.Config{
Endpoints: []string{ep},
})
Expand Down
8 changes: 4 additions & 4 deletions server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1293,22 +1293,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
2 changes: 1 addition & 1 deletion server/election/leadership_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (s *testLeadershipSuite) TestLeadership(c *C) {
}()
c.Assert(err, IsNil)

ep := cfg.LCUrls[0].String()
ep := cfg.ListenClientUrls[0].String()
client, err := clientv3.New(clientv3.Config{
Endpoints: []string{ep},
})
Expand Down
2 changes: 1 addition & 1 deletion server/election/lease_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (s *testLeaseSuite) TestLease(c *C) {
}()
c.Assert(err, IsNil)

ep := cfg.LCUrls[0].String()
ep := cfg.ListenClientUrls[0].String()
client, err := clientv3.New(clientv3.Config{
Endpoints: []string{ep},
})
Expand Down
12 changes: 6 additions & 6 deletions server/encryptionkm/key_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,20 @@ func newTestEtcd(c *C) (client *clientv3.Client, cleanup func()) {
cfg.Logger = "zap"
pu, err := url.Parse(tempurl.Alloc())
c.Assert(err, IsNil)
cfg.LPUrls = []url.URL{*pu}
cfg.APUrls = cfg.LPUrls
cfg.ListenPeerUrls = []url.URL{*pu}
cfg.AdvertisePeerUrls = cfg.ListenPeerUrls
cu, err := url.Parse(tempurl.Alloc())
c.Assert(err, IsNil)
cfg.LCUrls = []url.URL{*cu}
cfg.ACUrls = cfg.LCUrls
cfg.InitialCluster = fmt.Sprintf("%s=%s", cfg.Name, &cfg.LPUrls[0])
cfg.ListenClientUrls = []url.URL{*cu}
cfg.AdvertiseClientUrls = cfg.ListenClientUrls
cfg.InitialCluster = fmt.Sprintf("%s=%s", cfg.Name, &cfg.ListenPeerUrls[0])
cfg.ClusterState = embed.ClusterStateFlagNew
server, err := embed.StartEtcd(cfg)
c.Assert(err, IsNil)
<-server.Server.ReadyNotify()

client, err = clientv3.New(clientv3.Config{
Endpoints: []string{cfg.LCUrls[0].String()},
Endpoints: []string{cfg.ListenClientUrls[0].String()},
})
c.Assert(err, IsNil)

Expand Down
2 changes: 1 addition & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ func (s *Server) startEtcd(ctx context.Context) error {
return errs.ErrCancelStartEtcd.FastGenByArgs()
}

endpoints := []string{s.etcdCfg.ACUrls[0].String()}
endpoints := []string{s.etcdCfg.AdvertiseClientUrls[0].String()}
log.Info("create etcd v3 client", zap.Strings("endpoints", endpoints), zap.Reflect("cert", s.cfg.Security))

lgc := zap.NewProductionConfig()
Expand Down
12 changes: 6 additions & 6 deletions server/storage/kv/kv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (s *testKVSuite) TestEtcd(c *C) {
c.Assert(err, IsNil)
defer etcd.Close()

ep := cfg.LCUrls[0].String()
ep := cfg.ListenClientUrls[0].String()
client, err := clientv3.New(clientv3.Config{
Endpoints: []string{ep},
})
Expand Down Expand Up @@ -135,14 +135,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 Down
5 changes: 2 additions & 3 deletions tests/client/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ go 1.16

require (
github.com/gogo/protobuf v1.3.2
github.com/golang/protobuf v1.5.2 // indirect
github.com/pingcap/check v0.0.0-20211026125417-57bd13f7b5f0
github.com/pingcap/failpoint v0.0.0-20210918120811-547c13e3eb00
github.com/pingcap/kvproto v0.0.0-20220510035547-0e2f26c0a46a
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.20191023171146-3cf2f69b5738
go.etcd.io/etcd v0.5.0-alpha.5.0.20240131130919-ff2304879e1b
go.uber.org/goleak v1.1.12
google.golang.org/grpc v1.43.0
google.golang.org/grpc v1.58.3
)

replace (
Expand Down
Loading

0 comments on commit 2386ba1

Please sign in to comment.