From 2c0d131a89852ea57d8a5bfc2f37d6f77b32136d Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Fri, 26 Jan 2024 16:58:51 +0800 Subject: [PATCH] This is an automated cherry-pick of #7765 close tikv/pd#4399 Signed-off-by: ti-chi-bot --- pkg/schedule/config/config.go | 5 +++- server/cluster/cluster_test.go | 14 ++++++++++ .../mcs/scheduling/server_test.go | 27 +++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/pkg/schedule/config/config.go b/pkg/schedule/config/config.go index c8fa62b8aff..8c6829f769e 100644 --- a/pkg/schedule/config/config.go +++ b/pkg/schedule/config/config.go @@ -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"}, +>>>>>>> 5b939c6fc (config: disable witness related schedulers by default (#7765)) } // IsDefaultScheduler checks whether the scheduler is enable by default. diff --git a/server/cluster/cluster_test.go b/server/cluster/cluster_test.go index d1c8c8fe9cb..2fa47cb1085 100644 --- a/server/cluster/cluster_test.go +++ b/server/cluster/cluster_test.go @@ -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() @@ -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() @@ -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) diff --git a/tests/integrations/mcs/scheduling/server_test.go b/tests/integrations/mcs/scheduling/server_test.go index 324c8e5cad5..4654ff1c8af 100644 --- a/tests/integrations/mcs/scheduling/server_test.go +++ b/tests/integrations/mcs/scheduling/server_test.go @@ -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) { @@ -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) {