Skip to content

Commit

Permalink
--wip-- [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
rleungx committed Dec 5, 2024
1 parent 7c2ef71 commit 5d6c9f9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion pkg/schedule/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,11 @@ func (c *Coordinator) runPrepareChecker() {
case <-c.ctx.Done():
return
case <-ticker.C:
c.prepareChecker.Check(c.cluster.GetBasicCluster())
if !c.prepareChecker.IsPrepared() {
if c.prepareChecker.Check(c.cluster.GetBasicCluster()) {
log.Info("prepare checker is finished")
}
}
}
}
}
Expand Down
3 changes: 0 additions & 3 deletions pkg/schedule/core/prepare_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ func NewPrepareChecker() *PrepareChecker {

// Check checks if the coordinator has finished cluster information preparation.
func (checker *PrepareChecker) Check(c *core.BasicCluster) bool {
if checker.IsPrepared() {
return true
}
checker.Lock()
defer checker.Unlock()

Expand Down
3 changes: 3 additions & 0 deletions server/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2873,6 +2873,7 @@ func TestCheckCache(t *testing.T) {
cfg.ReplicaScheduleLimit = 0
}, nil, nil, re)
defer cleanup()
co.GetPrepareChecker().SetPrepared()
oc := co.GetOperatorController()
checker := co.GetCheckerController()

Expand Down Expand Up @@ -3028,6 +3029,7 @@ func TestPeerState(t *testing.T) {

tc, co, cleanup := prepare(nil, nil, func(co *schedule.Coordinator) { co.Run() }, re)
defer cleanup()
co.GetPrepareChecker().SetPrepared()

// Transfer peer from store 4 to store 1.
re.NoError(tc.addRegionStore(1, 10))
Expand Down Expand Up @@ -3072,6 +3074,7 @@ func TestAddScheduler(t *testing.T) {

tc, co, cleanup := prepare(nil, nil, func(co *schedule.Coordinator) { co.Run() }, re)
defer cleanup()
co.GetPrepareChecker().SetPrepared()
controller := co.GetSchedulersController()
re.Len(controller.GetSchedulerNames(), len(sc.DefaultSchedulers))
re.NoError(controller.RemoveScheduler(types.BalanceLeaderScheduler.String()))
Expand Down

0 comments on commit 5d6c9f9

Please sign in to comment.