From 5da6def96a3094385fdfd6d037a74845aaf51e4e Mon Sep 17 00:00:00 2001 From: lhy1024 Date: Fri, 12 Apr 2024 12:51:23 +0800 Subject: [PATCH] pd-ctl: hidden some hot scheduler config (#7892) ref tikv/pd#5691 Signed-off-by: lhy1024 Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com> --- tools/pd-ctl/pdctl/command/scheduler.go | 29 +++++++++++++++ .../pd-ctl/tests/scheduler/scheduler_test.go | 35 +++++++------------ 2 files changed, 42 insertions(+), 22 deletions(-) diff --git a/tools/pd-ctl/pdctl/command/scheduler.go b/tools/pd-ctl/pdctl/command/scheduler.go index d5deba670ad..c1db24cc176 100644 --- a/tools/pd-ctl/pdctl/command/scheduler.go +++ b/tools/pd-ctl/pdctl/command/scheduler.go @@ -649,6 +649,18 @@ func addStoreToSchedulerConfig(cmd *cobra.Command, schedulerName string, args [] postJSON(cmd, path.Join(schedulerConfigPrefix, schedulerName, "config"), input) } +var hiddenHotConfig = []string{ + "max-zombie-rounds", + "max-peer-number", + "byte-rate-rank-step-ratio", + "key-rate-rank-step-ratio", + "query-rate-rank-step-ratio", + "count-rank-step-ratio", + "great-dec-ratio", + "minor-dec-ratio", + "enable-for-tiflash", +} + func listSchedulerConfigCommandFunc(cmd *cobra.Command, args []string) { if len(args) != 0 { cmd.Println(cmd.UsageString()) @@ -667,6 +679,23 @@ func listSchedulerConfigCommandFunc(cmd *cobra.Command, args []string) { cmd.Println(err) return } + if p == "balance-hot-region-scheduler" { + schedulerConfig := make(map[string]any) + err := json.Unmarshal([]byte(r), &schedulerConfig) + if err != nil { + cmd.Println(err) + return + } + for _, config := range hiddenHotConfig { + delete(schedulerConfig, config) + } + b, err := json.MarshalIndent(schedulerConfig, "", " ") + if err != nil { + cmd.Println(err) + return + } + r = string(b) + } cmd.Println(r) } diff --git a/tools/pd-ctl/tests/scheduler/scheduler_test.go b/tools/pd-ctl/tests/scheduler/scheduler_test.go index b5a2128752b..00fab12b99b 100644 --- a/tools/pd-ctl/tests/scheduler/scheduler_test.go +++ b/tools/pd-ctl/tests/scheduler/scheduler_test.go @@ -386,28 +386,19 @@ func (suite *schedulerTestSuite) checkScheduler(cluster *pdTests.TestCluster) { // test hot region config expected1 := map[string]any{ - "min-hot-byte-rate": float64(100), - "min-hot-key-rate": float64(10), - "min-hot-query-rate": float64(10), - "max-zombie-rounds": float64(3), - "max-peer-number": float64(1000), - "byte-rate-rank-step-ratio": 0.05, - "key-rate-rank-step-ratio": 0.05, - "query-rate-rank-step-ratio": 0.05, - "count-rank-step-ratio": 0.01, - "great-dec-ratio": 0.95, - "minor-dec-ratio": 0.99, - "src-tolerance-ratio": 1.05, - "dst-tolerance-ratio": 1.05, - "read-priorities": []any{"byte", "key"}, - "write-leader-priorities": []any{"key", "byte"}, - "write-peer-priorities": []any{"byte", "key"}, - "strict-picking-store": "true", - "enable-for-tiflash": "true", - "rank-formula-version": "v2", - "split-thresholds": 0.2, - "history-sample-duration": "5m0s", - "history-sample-interval": "30s", + "min-hot-byte-rate": float64(100), + "min-hot-key-rate": float64(10), + "min-hot-query-rate": float64(10), + "src-tolerance-ratio": 1.05, + "dst-tolerance-ratio": 1.05, + "read-priorities": []any{"byte", "key"}, + "write-leader-priorities": []any{"key", "byte"}, + "write-peer-priorities": []any{"byte", "key"}, + "strict-picking-store": "true", + "rank-formula-version": "v2", + "split-thresholds": 0.2, + "history-sample-duration": "5m0s", + "history-sample-interval": "30s", } checkHotSchedulerConfig := func(expect map[string]any) { testutil.Eventually(re, func() bool {