Skip to content

Commit

Permalink
*: upgrade and adapt to the new PD client (#48575)
Browse files Browse the repository at this point in the history
ref #35319
  • Loading branch information
JmPotato authored Nov 14, 2023
1 parent 4793a04 commit 911334b
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 17 deletions.
12 changes: 6 additions & 6 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7132,13 +7132,13 @@ def go_deps():
name = "com_github_tikv_pd_client",
build_file_proto_mode = "disable_global",
importpath = "github.com/tikv/pd/client",
sha256 = "79a51a978de81c8a893e2b33c279ac84e3f95ccdf70cb7f62fef9a76472cd92b",
strip_prefix = "github.com/tikv/pd/[email protected]20230912103610-2f57a9f050eb",
sha256 = "cadd6f9cf411690e66fd2e5bad6ef837dd8522d98ddaf79a6a2f9361cbc558c1",
strip_prefix = "github.com/tikv/pd/[email protected]20231113092444-be31c08186fa",
urls = [
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20230912103610-2f57a9f050eb.zip",
"http://ats.apps.svc/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20230912103610-2f57a9f050eb.zip",
"https://cache.hawkingrei.com/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20230912103610-2f57a9f050eb.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20230912103610-2f57a9f050eb.zip",
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20231113092444-be31c08186fa.zip",
"http://ats.apps.svc/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20231113092444-be31c08186fa.zip",
"https://cache.hawkingrei.com/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20231113092444-be31c08186fa.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/pd/client/com_github_tikv_pd_client-v0.0.0-20231113092444-be31c08186fa.zip",
],
)
go_repository(
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ require (
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.20231030120815-1362f1e87566
github.com/tikv/pd/client v0.0.0-20230912103610-2f57a9f050eb
github.com/tikv/pd/client v0.0.0-20231113092444-be31c08186fa
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
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -993,8 +993,8 @@ github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a h1:J/YdBZ46WKpXsxsW
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a/go.mod h1:h4xBhSNtOeEosLJ4P7JyKXX7Cabg7AVkWCK5gV2vOrM=
github.com/tikv/client-go/v2 v2.0.8-0.20231030120815-1362f1e87566 h1:ULv8/h2S2daBtNDoovptSBC5fJEBKrx0K7E1K8iVOSw=
github.com/tikv/client-go/v2 v2.0.8-0.20231030120815-1362f1e87566/go.mod h1:XiEHwWZfJqgafxW/VEgi1ltGWB9yjwCJBs2kW1xHMY4=
github.com/tikv/pd/client v0.0.0-20230912103610-2f57a9f050eb h1:hAcH9tFjQzQ3+ofrAHm4ajOTLliYCOfXpj3+boKOtac=
github.com/tikv/pd/client v0.0.0-20230912103610-2f57a9f050eb/go.mod h1:E+6qtPu8fJm5kNjvKWPVFqSgNAFPk07y2EjD03GWzuI=
github.com/tikv/pd/client v0.0.0-20231113092444-be31c08186fa h1:qgbTvsjSzU2A9ItK+NUSUHgtvDTeaWk1mGH2Kjbaf7s=
github.com/tikv/pd/client v0.0.0-20231113092444-be31c08186fa/go.mod h1:cd6zBqRM9aogxf26K8NnFRPVtq9BnRE59tKEpX8IaWQ=
github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966 h1:quvGphlmUVU+nhpFa4gg4yJyTRJ13reZMDHrKwYw53M=
github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966/go.mod h1:27bSVNWSBOHm+qRp1T9qzaIpsWEP6TbUnei/43HK+PQ=
github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs=
Expand Down
6 changes: 5 additions & 1 deletion pkg/domain/infosync/resource_manager_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package infosync

import (
"bytes"
"context"
"fmt"
"math"
Expand Down Expand Up @@ -144,5 +145,8 @@ func (m *mockResourceManagerClient) LoadResourceGroups(ctx context.Context) ([]*
}

func (m *mockResourceManagerClient) Watch(ctx context.Context, key []byte, opts ...pd.OpOption) (chan []*meta_storagepb.Event, error) {
return m.eventCh, nil
if bytes.Equal(pd.GroupSettingsPathPrefixBytes, key) {
return m.eventCh, nil
}
return nil, nil
}
1 change: 1 addition & 0 deletions pkg/executor/internal/calibrateresource/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ go_test(
"//pkg/types",
"@com_github_pingcap_errors//:errors",
"@com_github_pingcap_failpoint//:failpoint",
"@com_github_pingcap_kvproto//pkg/meta_storagepb",
"@com_github_stretchr_testify//require",
"@com_github_tikv_client_go_v2//tikv",
"@com_github_tikv_pd_client//:client",
Expand Down
21 changes: 14 additions & 7 deletions pkg/executor/internal/calibrateresource/calibrate_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
package calibrateresource_test

import (
"bytes"
"context"
"encoding/json"
"testing"
"time"

"github.com/pingcap/errors"
"github.com/pingcap/failpoint"
"github.com/pingcap/kvproto/pkg/meta_storagepb"
"github.com/pingcap/tidb/pkg/domain"
"github.com/pingcap/tidb/pkg/parser/mysql"
"github.com/pingcap/tidb/pkg/testkit"
Expand Down Expand Up @@ -783,13 +785,18 @@ type mockResourceGroupProvider struct {
cfg rmclient.Config
}

func (p *mockResourceGroupProvider) LoadGlobalConfig(ctx context.Context, names []string, configPath string) ([]pd.GlobalConfigItem, int64, error) {
if configPath != "resource_group/controller" {
return nil, 0, errors.New("unsupported configPath")
func (p *mockResourceGroupProvider) Get(ctx context.Context, key []byte, opts ...pd.OpOption) (*meta_storagepb.GetResponse, error) {
if !bytes.Equal(pd.ControllerConfigPathPrefixBytes, key) {
return nil, errors.New("unsupported configPath")
}
payload, _ := json.Marshal(&p.cfg)
item := pd.GlobalConfigItem{
PayLoad: payload,
}
return []pd.GlobalConfigItem{item}, 0, nil
return &meta_storagepb.GetResponse{
Count: 1,
Kvs: []*meta_storagepb.KeyValue{
{
Key: key,
Value: payload,
},
},
}, nil
}

0 comments on commit 911334b

Please sign in to comment.