Skip to content

Commit

Permalink
Merge branch 'release-6.5' into cherry-pick-8264-to-release-6.5
Browse files Browse the repository at this point in the history
  • Loading branch information
HuSharp authored Aug 28, 2024
2 parents dc61385 + 83953be commit 09b4c87
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
33 changes: 31 additions & 2 deletions server/api/label_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
tu "github.com/tikv/pd/pkg/testutil"
"github.com/tikv/pd/server"
"github.com/tikv/pd/server/config"
"github.com/tikv/pd/server/core"
)

type labelsStoreTestSuite struct {
Expand Down Expand Up @@ -274,19 +275,47 @@ func (suite *strictlyLabelsStoreTestSuite) TestStoreMatch() {
valid: false,
expectError: "key matching the label was not found",
},
{
store: &metapb.Store{
Id: 3,
Address: "tiflash1",
State: metapb.StoreState_Up,
Labels: []*metapb.StoreLabel{
{
Key: "zone",
Value: "us-west-1",
},
{
Key: "disk",
Value: "ssd",
},
{
Key: core.EngineKey,
Value: core.EngineTiFlash,
},
},
Version: "3.0.0",
},
valid: true,
expectError: "placement rules is disabled",
},
}

for _, testCase := range testCases {
resp, err := suite.grpcSvr.PutStore(context.Background(), &pdpb.PutStoreRequest{
Header: &pdpb.RequestHeader{ClusterId: suite.svr.ClusterID()},
Store: &metapb.Store{
Id: testCase.store.Id,
Address: fmt.Sprintf("tikv%d", testCase.store.Id),
Address: testCase.store.Address,
State: testCase.store.State,
Labels: testCase.store.Labels,
Version: testCase.store.Version,
},
})
if testCase.store.Address == "tiflash1" {
suite.Contains(resp.GetHeader().GetError().String(), testCase.expectError)
continue
}
if testCase.valid {
suite.NoError(err)
suite.Nil(resp.GetHeader().GetError())
Expand All @@ -306,7 +335,7 @@ func (suite *strictlyLabelsStoreTestSuite) TestStoreMatch() {
Header: &pdpb.RequestHeader{ClusterId: suite.svr.ClusterID()},
Store: &metapb.Store{
Id: testCase.store.Id,
Address: fmt.Sprintf("tikv%d", testCase.store.Id),
Address: testCase.store.Address,
State: testCase.store.State,
Labels: testCase.store.Labels,
Version: testCase.store.Version,
Expand Down
3 changes: 3 additions & 0 deletions server/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,9 @@ func (c *RaftCluster) checkStoreLabels(s *core.StoreInfo) error {
}
for _, label := range s.GetLabels() {
key := label.GetKey()
if key == core.EngineKey {
continue
}
if _, ok := keysSet[key]; !ok {
log.Warn("not found the key match with the store label",
zap.Stringer("store", s.GetMeta()),
Expand Down
4 changes: 2 additions & 2 deletions server/cluster/cluster_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func (c *RaftCluster) HandleBatchReportSplit(request *pdpb.ReportBatchSplitReque
err := c.checkSplitRegions(regions)
if err != nil {
log.Warn("report batch split region is invalid",
zap.Stringer("region-meta", hrm),
logutil.ZapRedactStringer("region-meta", hrm),
errs.ZapError(err))
return nil, err
}
Expand All @@ -236,7 +236,7 @@ func (c *RaftCluster) HandleBatchReportSplit(request *pdpb.ReportBatchSplitReque
hrm = core.RegionsToHexMeta(regions[:last])
log.Info("region batch split, generate new regions",
zap.Uint64("region-id", originRegion.GetId()),
zap.Stringer("origin", hrm),
logutil.ZapRedactStringer("origin", hrm),
zap.Int("total", last))
return &pdpb.ReportBatchSplitResponse{}, nil
}
Expand Down

0 comments on commit 09b4c87

Please sign in to comment.