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

*: impl mock PD service discovery and update pd client version #50718

Merged
merged 8 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 36 additions & 36 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1061,13 +1061,13 @@ def go_deps():
name = "com_github_cncf_xds_go",
build_file_proto_mode = "disable_global",
importpath = "github.com/cncf/xds/go",
sha256 = "a0c6e66eade357aeda4edaa9d09612085860dc4c0b44edf8226574939bdf6091",
strip_prefix = "github.com/cncf/xds/go@v0.0.0-20230607035331-e9ce68804cb4",
sha256 = "abb811f8a32a7b60656a02e2a3500455ae907e1e0c35a1012a61599795bb3b73",
strip_prefix = "github.com/cncf/xds/go@v0.0.0-20231109132714-523115ebc101",
urls = [
"http://bazel-cache.pingcap.net:8080/gomod/github.com/cncf/xds/go/com_github_cncf_xds_go-v0.0.0-20230607035331-e9ce68804cb4.zip",
"http://ats.apps.svc/gomod/github.com/cncf/xds/go/com_github_cncf_xds_go-v0.0.0-20230607035331-e9ce68804cb4.zip",
"https://cache.hawkingrei.com/gomod/github.com/cncf/xds/go/com_github_cncf_xds_go-v0.0.0-20230607035331-e9ce68804cb4.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/cncf/xds/go/com_github_cncf_xds_go-v0.0.0-20230607035331-e9ce68804cb4.zip",
"http://bazel-cache.pingcap.net:8080/gomod/github.com/cncf/xds/go/com_github_cncf_xds_go-v0.0.0-20231109132714-523115ebc101.zip",
"http://ats.apps.svc/gomod/github.com/cncf/xds/go/com_github_cncf_xds_go-v0.0.0-20231109132714-523115ebc101.zip",
"https://cache.hawkingrei.com/gomod/github.com/cncf/xds/go/com_github_cncf_xds_go-v0.0.0-20231109132714-523115ebc101.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/cncf/xds/go/com_github_cncf_xds_go-v0.0.0-20231109132714-523115ebc101.zip",
],
)
go_repository(
Expand Down Expand Up @@ -7032,26 +7032,26 @@ def go_deps():
name = "com_github_tikv_client_go_v2",
build_file_proto_mode = "disable_global",
importpath = "github.com/tikv/client-go/v2",
sha256 = "dfc92ddf47606d8e9d9fe165f4cb344f1ad631f04bcd7f372e11266d6a2206bc",
strip_prefix = "github.com/tikv/client-go/v2@v2.0.8-0.20240123055405-3480b5ed7ce1",
sha256 = "92c59118dae5c4d9255f2ac61dd137c3bea7b195c96047e29161414c6ab8d516",
strip_prefix = "github.com/tikv/client-go/v2@v2.0.8-0.20240124081343-99ea0d4d9bb1",
urls = [
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20240123055405-3480b5ed7ce1.zip",
"http://ats.apps.svc/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20240123055405-3480b5ed7ce1.zip",
"https://cache.hawkingrei.com/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20240123055405-3480b5ed7ce1.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20240123055405-3480b5ed7ce1.zip",
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20240124081343-99ea0d4d9bb1.zip",
"http://ats.apps.svc/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20240124081343-99ea0d4d9bb1.zip",
"https://cache.hawkingrei.com/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20240124081343-99ea0d4d9bb1.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20240124081343-99ea0d4d9bb1.zip",
],
)
go_repository(
name = "com_github_tikv_pd_client",
build_file_proto_mode = "disable_global",
importpath = "github.com/tikv/pd/client",
sha256 = "ea1ce959374afae8cbe31345e696f5731443c9ea6029de46fcf6844c09677c9c",
strip_prefix = "github.com/tikv/pd/client@v0.0.0-20240109100024-dd8df25316e9",
sha256 = "bc13e2163218ee2f475cbf4e2560b60148b73a9995f4a60c85c1fc01dd2b1039",
strip_prefix = "github.com/tikv/pd/client@v0.0.0-20240124074521-ca8fd3db3e33",
urls = [
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20240109100024-dd8df25316e9.zip",
"http://ats.apps.svc/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20240109100024-dd8df25316e9.zip",
"https://cache.hawkingrei.com/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20240109100024-dd8df25316e9.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20240109100024-dd8df25316e9.zip",
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20240124074521-ca8fd3db3e33.zip",
"http://ats.apps.svc/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20240124074521-ca8fd3db3e33.zip",
"https://cache.hawkingrei.com/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20240124074521-ca8fd3db3e33.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20240124074521-ca8fd3db3e33.zip",
],
)
go_repository(
Expand Down Expand Up @@ -10026,13 +10026,13 @@ def go_deps():
name = "org_golang_google_genproto",
build_file_proto_mode = "disable_global",
importpath = "google.golang.org/genproto",
sha256 = "5ed90251b73540d8576554928e989df1e0ab81f91a487960f0c93c77ff2e38c0",
strip_prefix = "google.golang.org/genproto@v0.0.0-20240108191215-35c7eff3a6b1",
sha256 = "e65fb3abc11c20b0910c40a3b269b79b06c2cdd6e7efab29a5ea50f18a62b7f9",
strip_prefix = "google.golang.org/genproto@v0.0.0-20240116215550-a9fa1716bcac",
urls = [
"http://bazel-cache.pingcap.net:8080/gomod/google.golang.org/genproto/org_golang_google_genproto-v0.0.0-20240108191215-35c7eff3a6b1.zip",
"http://ats.apps.svc/gomod/google.golang.org/genproto/org_golang_google_genproto-v0.0.0-20240108191215-35c7eff3a6b1.zip",
"https://cache.hawkingrei.com/gomod/google.golang.org/genproto/org_golang_google_genproto-v0.0.0-20240108191215-35c7eff3a6b1.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/google.golang.org/genproto/org_golang_google_genproto-v0.0.0-20240108191215-35c7eff3a6b1.zip",
"http://bazel-cache.pingcap.net:8080/gomod/google.golang.org/genproto/org_golang_google_genproto-v0.0.0-20240116215550-a9fa1716bcac.zip",
"http://ats.apps.svc/gomod/google.golang.org/genproto/org_golang_google_genproto-v0.0.0-20240116215550-a9fa1716bcac.zip",
"https://cache.hawkingrei.com/gomod/google.golang.org/genproto/org_golang_google_genproto-v0.0.0-20240116215550-a9fa1716bcac.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/google.golang.org/genproto/org_golang_google_genproto-v0.0.0-20240116215550-a9fa1716bcac.zip",
],
)
go_repository(
Expand Down Expand Up @@ -10065,26 +10065,26 @@ def go_deps():
name = "org_golang_google_genproto_googleapis_rpc",
build_file_proto_mode = "disable_global",
importpath = "google.golang.org/genproto/googleapis/rpc",
sha256 = "4e4c60b74b5bba370fbba795eab6313e42b6eabd668aea1ed87a5b25065ec144",
strip_prefix = "google.golang.org/genproto/googleapis/rpc@v0.0.0-20240108191215-35c7eff3a6b1",
sha256 = "1a8c10b3ca5a0aea26bb78d948edbcc126ce7e07e127f6f7a23af5e5d641b40f",
strip_prefix = "google.golang.org/genproto/googleapis/rpc@v0.0.0-20240123012728-ef4313101c80",
urls = [
"http://bazel-cache.pingcap.net:8080/gomod/google.golang.org/genproto/googleapis/rpc/org_golang_google_genproto_googleapis_rpc-v0.0.0-20240108191215-35c7eff3a6b1.zip",
"http://ats.apps.svc/gomod/google.golang.org/genproto/googleapis/rpc/org_golang_google_genproto_googleapis_rpc-v0.0.0-20240108191215-35c7eff3a6b1.zip",
"https://cache.hawkingrei.com/gomod/google.golang.org/genproto/googleapis/rpc/org_golang_google_genproto_googleapis_rpc-v0.0.0-20240108191215-35c7eff3a6b1.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/google.golang.org/genproto/googleapis/rpc/org_golang_google_genproto_googleapis_rpc-v0.0.0-20240108191215-35c7eff3a6b1.zip",
"http://bazel-cache.pingcap.net:8080/gomod/google.golang.org/genproto/googleapis/rpc/org_golang_google_genproto_googleapis_rpc-v0.0.0-20240123012728-ef4313101c80.zip",
"http://ats.apps.svc/gomod/google.golang.org/genproto/googleapis/rpc/org_golang_google_genproto_googleapis_rpc-v0.0.0-20240123012728-ef4313101c80.zip",
"https://cache.hawkingrei.com/gomod/google.golang.org/genproto/googleapis/rpc/org_golang_google_genproto_googleapis_rpc-v0.0.0-20240123012728-ef4313101c80.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/google.golang.org/genproto/googleapis/rpc/org_golang_google_genproto_googleapis_rpc-v0.0.0-20240123012728-ef4313101c80.zip",
],
)
go_repository(
name = "org_golang_google_grpc",
build_file_proto_mode = "disable_global",
importpath = "google.golang.org/grpc",
sha256 = "c9088df910b74b8a815c2eabf7e7b458aa9a355312aee77994d5d8f6ca24928a",
strip_prefix = "google.golang.org/grpc@v1.60.1",
sha256 = "6971b322a68f83ae2055391e5bd57dfb359e67509961a75229b825d2bd15564d",
strip_prefix = "google.golang.org/grpc@v1.61.0",
urls = [
"http://bazel-cache.pingcap.net:8080/gomod/google.golang.org/grpc/org_golang_google_grpc-v1.60.1.zip",
"http://ats.apps.svc/gomod/google.golang.org/grpc/org_golang_google_grpc-v1.60.1.zip",
"https://cache.hawkingrei.com/gomod/google.golang.org/grpc/org_golang_google_grpc-v1.60.1.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/google.golang.org/grpc/org_golang_google_grpc-v1.60.1.zip",
"http://bazel-cache.pingcap.net:8080/gomod/google.golang.org/grpc/org_golang_google_grpc-v1.61.0.zip",
"http://ats.apps.svc/gomod/google.golang.org/grpc/org_golang_google_grpc-v1.61.0.zip",
"https://cache.hawkingrei.com/gomod/google.golang.org/grpc/org_golang_google_grpc-v1.61.0.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/google.golang.org/grpc/org_golang_google_grpc-v1.61.0.zip",
],
)
go_repository(
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/backup/prepare_snap/prepare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func (m *mockStores) AssertIsNormalMode(t *testing.T) {

func fakeCluster(t *testing.T, nodes int, keys ...[]byte) pd.Client {
tmp := t.TempDir()
_, pdc, cluster, err := unistore.New(tmp)
_, pdc, cluster, err := unistore.New(tmp, nil)
unistore.BootstrapWithMultiStores(cluster, nodes)
require.NoError(t, err)
cluster.SplitArbitrary(keys...)
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/lightning/backend/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ func NewBackend(
if err != nil {
return nil, common.ErrCreateKVClient.Wrap(err).GenWithStackByArgs()
}
pdHTTPCli := pdhttp.NewClient("lightning", pdAddrs, pdhttp.WithTLSConfig(tls.TLSConfig())).
pdHTTPCli := pdhttp.NewClientWithServiceDiscovery("lightning", pdCli.GetServiceDiscovery(), pdhttp.WithTLSConfig(tls.TLSConfig())).
WithBackoffer(retry.InitialBackoffer(time.Second, time.Second, pdutil.PDRequestRetryTime*time.Second))
splitCli := split.NewSplitClient(pdCli, pdHTTPCli, tls.TLSConfig(), false)
importClientFactory := newImportClientFactoryImpl(splitCli, tls, config.MaxConnPerStore, config.ConnCompressType)
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/lightning/importer/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ func NewImportControllerWithPauser(
if err != nil {
return nil, errors.Trace(err)
}
pdHTTPCli = pdhttp.NewClient("lightning", addrs, pdhttp.WithTLSConfig(tls.TLSConfig()))
pdHTTPCli = pdhttp.NewClientWithServiceDiscovery("lightning", pdCli.GetServiceDiscovery(), pdhttp.WithTLSConfig(tls.TLSConfig()))

if cfg.TikvImporter.DuplicateResolution != config.DupeResAlgNone {
if err := tikv.CheckTiKVVersion(ctx, pdHTTPCli, minTiKVVersionForDuplicateResolution, maxTiKVVersionForDuplicateResolution); err != nil {
Expand Down
1 change: 1 addition & 0 deletions br/pkg/pdutil/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ go_test(
flaky = True,
shard_count = 8,
deps = [
"//pkg/store/mockstore/unistore",
"//pkg/store/pdtypes",
"//pkg/testkit/testsetup",
"//pkg/util/codec",
Expand Down
5 changes: 4 additions & 1 deletion br/pkg/pdutil/pd.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,10 @@ func NewPdController(
if tlsConf != nil {
pdHTTPCliConfig = append(pdHTTPCliConfig, pdhttp.WithTLSConfig(tlsConf))
}
pdHTTPCli := pdhttp.NewClient("br/lightning PD controller", addrs, pdHTTPCliConfig...).
pdHTTPCli := pdhttp.NewClientWithServiceDiscovery(
"br/lightning PD controller",
pdClient.GetServiceDiscovery(),
pdHTTPCliConfig...).
WithBackoffer(retry.InitialBackoffer(time.Second, time.Second, PDRequestRetryTime*time.Second))
return &PdController{
addrs: processedAddrs,
Expand Down
3 changes: 2 additions & 1 deletion br/pkg/pdutil/pd_serial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/coreos/go-semver/semver"
"github.com/pingcap/failpoint"
"github.com/pingcap/kvproto/pkg/metapb"
"github.com/pingcap/tidb/pkg/store/mockstore/unistore"
"github.com/pingcap/tidb/pkg/store/pdtypes"
"github.com/pingcap/tidb/pkg/util/codec"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -337,7 +338,7 @@ func TestPauseSchedulersByKeyRange(t *testing.T) {
}))
defer httpSrv.Close()

pdHTTPCli := pdhttp.NewClient("test", []string{httpSrv.URL})
pdHTTPCli := pdhttp.NewClientWithServiceDiscovery("test", unistore.NewMockPDServiceDiscovery([]string{httpSrv.URL}))
defer pdHTTPCli.Close()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down
11 changes: 6 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
github.com/Shopify/sarama v1.29.0
github.com/aliyun/alibaba-cloud-sdk-go v1.61.1581
github.com/apache/skywalking-eyes v0.4.0
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2
github.com/ashanbrown/makezero v1.1.1
github.com/aws/aws-sdk-go v1.45.25
github.com/bazelbuild/buildtools v0.0.0-20230926111657-7d855c59baeb
Expand Down Expand Up @@ -106,8 +107,8 @@ require (
github.com/stretchr/testify v1.8.4
github.com/tdakkota/asciicheck v0.2.0
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2
github.com/tikv/client-go/v2 v2.0.8-0.20240123055405-3480b5ed7ce1
github.com/tikv/pd/client v0.0.0-20240109100024-dd8df25316e9
github.com/tikv/client-go/v2 v2.0.8-0.20240124081343-99ea0d4d9bb1
github.com/tikv/pd/client v0.0.0-20240124074521-ca8fd3db3e33
github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966
github.com/twmb/murmur3 v1.1.6
github.com/uber/jaeger-client-go v2.22.1+incompatible
Expand Down Expand Up @@ -137,7 +138,7 @@ require (
golang.org/x/time v0.5.0
golang.org/x/tools v0.17.0
google.golang.org/api v0.156.0
google.golang.org/grpc v1.60.1
google.golang.org/grpc v1.61.0
gopkg.in/yaml.v2 v2.4.0
honnef.co/go/tools v0.4.6
k8s.io/api v0.28.2
Expand Down Expand Up @@ -166,7 +167,7 @@ require (
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 // indirect
go.opentelemetry.io/otel/metric v1.21.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240108191215-35c7eff3a6b1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
k8s.io/utils v0.0.0-20230711102312-30195339c3c7 // indirect
)

Expand Down Expand Up @@ -298,7 +299,7 @@ require (
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
gonum.org/v1/gonum v0.8.2 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240108191215-35c7eff3a6b1 // indirect
google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
Expand Down
Loading
Loading