Skip to content

Commit

Permalink
fix sync store label
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx committed Nov 20, 2023
1 parent 49b3251 commit eee09c4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/mcs/scheduling/server/meta/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ func (w *Watcher) initializeStoreWatcher() error {
w.basicCluster.PutStore(core.NewStoreInfo(store))
return nil
}
w.basicCluster.PutStore(origin.Clone(core.SetStoreState(store.GetState(), store.GetPhysicallyDestroyed())))
w.basicCluster.PutStore(origin.Clone(
core.SetStoreState(store.GetState(), store.GetPhysicallyDestroyed()),
core.SetStoreLabels(store.GetLabels()),
))
return nil
}
deleteFn := func(kv *mvccpb.KeyValue) error {
Expand Down
11 changes: 11 additions & 0 deletions tests/integrations/mcs/scheduling/meta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,15 @@ func (suite *metaTestSuite) TestStoreWatch() {
testutil.Eventually(re, func() bool {
return cluster.GetStore(2) == nil
})

// test synchronized store labels
suite.pdLeaderServer.GetServer().GetRaftCluster().PutStore(
&metapb.Store{Id: 5, Address: "mock-5", State: metapb.StoreState_Up, NodeState: metapb.NodeState_Serving, LastHeartbeat: time.Now().UnixNano(), Labels: []*metapb.StoreLabel{{Key: "zone", Value: "z1"}}},
)
testutil.Eventually(re, func() bool {
if len(cluster.GetStore(5).GetLabels()) == 0 {
return false
}
return cluster.GetStore(5).GetLabels()[0].GetValue() == "z1"
})
}

0 comments on commit eee09c4

Please sign in to comment.