From 3f32f547ff18219103efb0e36d24de4eacce6d67 Mon Sep 17 00:00:00 2001 From: okJiang <819421878@qq.com> Date: Mon, 12 Aug 2024 14:16:31 +0800 Subject: [PATCH] config: Deprecate `SchedulersPayload` (#8509) ref tikv/pd#8474 Signed-off-by: okJiang <819421878@qq.com> Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com> --- pkg/mcs/scheduling/server/server.go | 8 -------- pkg/schedule/config/config.go | 4 ---- server/api/config.go | 1 - server/server.go | 10 ---------- tests/integrations/mcs/scheduling/api_test.go | 13 +------------ tools/pd-ctl/pdctl/command/config_command.go | 1 - tools/pd-ctl/tests/config/config_test.go | 1 - 7 files changed, 1 insertion(+), 37 deletions(-) diff --git a/pkg/mcs/scheduling/server/server.go b/pkg/mcs/scheduling/server/server.go index 50936325f45..eaf29b81fc0 100644 --- a/pkg/mcs/scheduling/server/server.go +++ b/pkg/mcs/scheduling/server/server.go @@ -540,14 +540,6 @@ func (s *Server) GetConfig() *config.Config { cfg.Schedule = *s.persistConfig.GetScheduleConfig().Clone() cfg.Replication = *s.persistConfig.GetReplicationConfig().Clone() cfg.ClusterVersion = *s.persistConfig.GetClusterVersion() - if s.storage == nil { - return cfg - } - sches, configs, err := s.storage.LoadAllSchedulerConfigs() - if err != nil { - return cfg - } - cfg.Schedule.SchedulersPayload = schedulers.ToPayload(sches, configs) return cfg } diff --git a/pkg/schedule/config/config.go b/pkg/schedule/config/config.go index 08bcc57ffe2..124bff0a704 100644 --- a/pkg/schedule/config/config.go +++ b/pkg/schedule/config/config.go @@ -278,9 +278,6 @@ type ScheduleConfig struct { // Schedulers support for loading customized schedulers Schedulers SchedulerConfigs `toml:"schedulers" json:"schedulers-v2"` // json v2 is for the sake of compatible upgrade - // Only used to display - SchedulersPayload map[string]any `toml:"schedulers-payload" json:"schedulers-payload"` - // Controls the time interval between write hot regions info into leveldb. HotRegionsWriteInterval typeutil.Duration `toml:"hot-regions-write-interval" json:"hot-regions-write-interval"` @@ -324,7 +321,6 @@ func (c *ScheduleConfig) Clone() *ScheduleConfig { cfg := *c cfg.StoreLimit = storeLimit cfg.Schedulers = schedulers - cfg.SchedulersPayload = nil return &cfg } diff --git a/server/api/config.go b/server/api/config.go index 88cb17783bc..c5681f9bbea 100644 --- a/server/api/config.go +++ b/server/api/config.go @@ -343,7 +343,6 @@ func (h *confHandler) GetScheduleConfig(w http.ResponseWriter, r *http.Request) h.rd.JSON(w, http.StatusInternalServerError, err.Error()) return } - cfg.Schedule.SchedulersPayload = nil h.rd.JSON(w, http.StatusOK, cfg.Schedule) return } diff --git a/server/server.go b/server/server.go index a08d31b2945..1c42070cfe3 100644 --- a/server/server.go +++ b/server/server.go @@ -63,7 +63,6 @@ import ( sc "github.com/tikv/pd/pkg/schedule/config" "github.com/tikv/pd/pkg/schedule/hbstream" "github.com/tikv/pd/pkg/schedule/placement" - "github.com/tikv/pd/pkg/schedule/schedulers" "github.com/tikv/pd/pkg/storage" "github.com/tikv/pd/pkg/storage/endpoint" "github.com/tikv/pd/pkg/storage/kv" @@ -982,14 +981,6 @@ func (s *Server) GetConfig() *config.Config { cfg.MicroService = *s.persistOptions.GetMicroServiceConfig().Clone() cfg.LabelProperty = s.persistOptions.GetLabelPropertyConfig().Clone() cfg.ClusterVersion = *s.persistOptions.GetClusterVersion() - if s.storage == nil { - return cfg - } - sches, configs, err := s.storage.LoadAllSchedulerConfigs() - if err != nil { - return cfg - } - cfg.Schedule.SchedulersPayload = schedulers.ToPayload(sches, configs) return cfg } @@ -1054,7 +1045,6 @@ func (s *Server) SetScheduleConfig(cfg sc.ScheduleConfig) error { return err } old := s.persistOptions.GetScheduleConfig() - cfg.SchedulersPayload = nil s.persistOptions.SetScheduleConfig(&cfg) if err := s.persistOptions.Persist(s.storage); err != nil { s.persistOptions.SetScheduleConfig(old) diff --git a/tests/integrations/mcs/scheduling/api_test.go b/tests/integrations/mcs/scheduling/api_test.go index eba94213d7e..4425369ed71 100644 --- a/tests/integrations/mcs/scheduling/api_test.go +++ b/tests/integrations/mcs/scheduling/api_test.go @@ -395,14 +395,6 @@ func (suite *apiTestSuite) checkConfig(cluster *tests.TestCluster) { re.Equal(cfg.Replication.MaxReplicas, s.GetConfig().Replication.MaxReplicas) re.Equal(cfg.Replication.LocationLabels, s.GetConfig().Replication.LocationLabels) re.Equal(cfg.DataDir, s.GetConfig().DataDir) - testutil.Eventually(re, func() bool { - // wait for all schedulers to be loaded in scheduling server. - return len(cfg.Schedule.SchedulersPayload) == 4 - }) - re.Contains(cfg.Schedule.SchedulersPayload, "balance-leader-scheduler") - re.Contains(cfg.Schedule.SchedulersPayload, "balance-region-scheduler") - re.Contains(cfg.Schedule.SchedulersPayload, "balance-hot-region-scheduler") - re.Contains(cfg.Schedule.SchedulersPayload, "evict-slow-store-scheduler") } func (suite *apiTestSuite) TestConfigForward() { @@ -423,10 +415,7 @@ func (suite *apiTestSuite) checkConfigForward(cluster *tests.TestCluster) { testutil.ReadGetJSON(re, tests.TestDialClient, urlPrefix, &cfg) re.Equal(cfg["schedule"].(map[string]any)["leader-schedule-limit"], float64(opts.GetLeaderScheduleLimit())) - re.Equal(cfg["replication"].(map[string]any)["max-replicas"], - float64(opts.GetReplicationConfig().MaxReplicas)) - schedulers := cfg["schedule"].(map[string]any)["schedulers-payload"].(map[string]any) - return len(schedulers) == 4 + return cfg["replication"].(map[string]any)["max-replicas"] == float64(opts.GetReplicationConfig().MaxReplicas) }) // Test to change config in api server diff --git a/tools/pd-ctl/pdctl/command/config_command.go b/tools/pd-ctl/pdctl/command/config_command.go index 0c3851350cc..6f88e06a0dd 100644 --- a/tools/pd-ctl/pdctl/command/config_command.go +++ b/tools/pd-ctl/pdctl/command/config_command.go @@ -255,7 +255,6 @@ func showConfigCommandFunc(cmd *cobra.Command, _ []string) { var hideConfig = []string{ "schedulers-v2", - "schedulers-payload", "store-limit", "enable-remove-down-replica", "enable-replace-offline-replica", diff --git a/tools/pd-ctl/tests/config/config_test.go b/tools/pd-ctl/tests/config/config_test.go index f3c261e1f49..0404796a81e 100644 --- a/tools/pd-ctl/tests/config/config_test.go +++ b/tools/pd-ctl/tests/config/config_test.go @@ -130,7 +130,6 @@ func (suite *configTestSuite) checkConfig(cluster *pdTests.TestCluster) { // hidden config scheduleConfig.Schedulers = nil - scheduleConfig.SchedulersPayload = nil scheduleConfig.StoreLimit = nil scheduleConfig.SchedulerMaxWaitingOperator = 0 scheduleConfig.EnableRemoveDownReplica = false