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

config: disable witness related schedulers by default (#7765) #8892

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion pkg/schedule/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,9 +525,12 @@ type SchedulerConfig struct {
var DefaultSchedulers = SchedulerConfigs{
{Type: "balance-region"},
{Type: "balance-leader"},
{Type: "balance-witness"},
{Type: "hot-region"},
<<<<<<< HEAD
{Type: "transfer-witness-leader"},
=======
{Type: "evict-slow-store"},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add it?

>>>>>>> 5b939c6fc (config: disable witness related schedulers by default (#7765))
}

// IsDefaultScheduler checks whether the scheduler is enable by default.
Expand Down
14 changes: 14 additions & 0 deletions server/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3041,8 +3041,12 @@ func TestAddScheduler(t *testing.T) {
re.NoError(controller.RemoveScheduler(schedulers.BalanceLeaderName))
re.NoError(controller.RemoveScheduler(schedulers.BalanceRegionName))
re.NoError(controller.RemoveScheduler(schedulers.HotRegionName))
<<<<<<< HEAD
re.NoError(controller.RemoveScheduler(schedulers.BalanceWitnessName))
re.NoError(controller.RemoveScheduler(schedulers.TransferWitnessLeaderName))
=======
re.NoError(controller.RemoveScheduler(schedulers.EvictSlowStoreName))
>>>>>>> 5b939c6fc (config: disable witness related schedulers by default (#7765))
re.Empty(controller.GetSchedulerNames())

stream := mockhbstream.NewHeartbeatStream()
Expand Down Expand Up @@ -3137,9 +3141,15 @@ func TestPersistScheduler(t *testing.T) {
re.NoError(controller.RemoveScheduler(schedulers.BalanceLeaderName))
re.NoError(controller.RemoveScheduler(schedulers.BalanceRegionName))
re.NoError(controller.RemoveScheduler(schedulers.HotRegionName))
<<<<<<< HEAD
re.NoError(controller.RemoveScheduler(schedulers.BalanceWitnessName))
re.NoError(controller.RemoveScheduler(schedulers.TransferWitnessLeaderName))
re.Len(controller.GetSchedulerNames(), defaultCount-3)
=======
re.NoError(controller.RemoveScheduler(schedulers.EvictSlowStoreName))
// only remains 2 items with independent config.
re.Len(controller.GetSchedulerNames(), 2)
>>>>>>> 5b939c6fc (config: disable witness related schedulers by default (#7765))
re.NoError(co.GetCluster().GetSchedulerConfig().Persist(storage))
co.Stop()
co.GetSchedulersController().Wait()
Expand Down Expand Up @@ -3249,8 +3259,12 @@ func TestRemoveScheduler(t *testing.T) {
re.NoError(controller.RemoveScheduler(schedulers.BalanceRegionName))
re.NoError(controller.RemoveScheduler(schedulers.HotRegionName))
re.NoError(controller.RemoveScheduler(schedulers.GrantLeaderName))
<<<<<<< HEAD
re.NoError(controller.RemoveScheduler(schedulers.BalanceWitnessName))
re.NoError(controller.RemoveScheduler(schedulers.TransferWitnessLeaderName))
=======
re.NoError(controller.RemoveScheduler(schedulers.EvictSlowStoreName))
>>>>>>> 5b939c6fc (config: disable witness related schedulers by default (#7765))
// all removed
sches, _, err = storage.LoadAllSchedulerConfigs()
re.NoError(err)
Expand Down
27 changes: 27 additions & 0 deletions tests/integrations/mcs/scheduling/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ func (suite *serverTestSuite) TestSchedulerSync() {
api.MustDeleteScheduler(re, suite.backendEndpoints, schedulers.EvictLeaderName)
checkEvictLeaderSchedulerExist(re, schedulersController, false)

<<<<<<< HEAD
// TODO: test more schedulers.
// Fixme: the following code will fail because the scheduler is not removed but not synced.
// checkDelete := func(schedulerName string) {
Expand All @@ -277,6 +278,32 @@ func (suite *serverTestSuite) TestSchedulerSync() {
// checkDelete(schedulers.BalanceLeaderName)
// checkDelete(schedulers.BalanceRegionName)
// checkDelete(schedulers.HotRegionName)
=======
// The default scheduler could not be deleted, it could only be disabled.
defaultSchedulerNames := []string{
schedulers.BalanceLeaderName,
schedulers.BalanceRegionName,
schedulers.HotRegionName,
}
checkDisabled := func(name string, shouldDisabled bool) {
re.NotNil(schedulersController.GetScheduler(name), name)
testutil.Eventually(re, func() bool {
disabled, err := schedulersController.IsSchedulerDisabled(name)
re.NoError(err, name)
return disabled == shouldDisabled
})
}
for _, name := range defaultSchedulerNames {
checkDisabled(name, false)
api.MustDeleteScheduler(re, suite.backendEndpoints, name)
checkDisabled(name, true)
}
for _, name := range defaultSchedulerNames {
checkDisabled(name, true)
api.MustAddScheduler(re, suite.backendEndpoints, name, nil)
checkDisabled(name, false)
}
>>>>>>> 5b939c6fc (config: disable witness related schedulers by default (#7765))
}

func checkEvictLeaderSchedulerExist(re *require.Assertions, sc *schedulers.Controller, exist bool) {
Expand Down
Loading