diff --git a/pkg/schedule/schedulers/balance_leader.go b/pkg/schedule/schedulers/balance_leader.go index ef3cdc9a144..ce3d566770c 100644 --- a/pkg/schedule/schedulers/balance_leader.go +++ b/pkg/schedule/schedulers/balance_leader.go @@ -145,6 +145,9 @@ func (handler *balanceLeaderHandler) updateConfig(w http.ResponseWriter, r *http } func (handler *balanceLeaderHandler) listConfig(w http.ResponseWriter, _ *http.Request) { + if handler.config.isDisable() { + handler.rd.JSON(w, http.StatusNotFound, errs.ErrSchedulerNotFound.Error()) + } conf := handler.config.clone() handler.rd.JSON(w, http.StatusOK, conf) } diff --git a/pkg/schedule/schedulers/evict_slow_store.go b/pkg/schedule/schedulers/evict_slow_store.go index 56599439665..9a2fd1590d9 100644 --- a/pkg/schedule/schedulers/evict_slow_store.go +++ b/pkg/schedule/schedulers/evict_slow_store.go @@ -23,6 +23,7 @@ import ( "github.com/pingcap/failpoint" "github.com/pingcap/log" "github.com/tikv/pd/pkg/core" + "github.com/tikv/pd/pkg/errs" sche "github.com/tikv/pd/pkg/schedule/core" "github.com/tikv/pd/pkg/schedule/operator" "github.com/tikv/pd/pkg/schedule/plan" @@ -162,6 +163,9 @@ func (handler *evictSlowStoreHandler) updateConfig(w http.ResponseWriter, r *htt } func (handler *evictSlowStoreHandler) listConfig(w http.ResponseWriter, _ *http.Request) { + if handler.config.isDisable() { + handler.rd.JSON(w, http.StatusNotFound, errs.ErrSchedulerNotFound.Error()) + } conf := handler.config.clone() handler.rd.JSON(w, http.StatusOK, conf) } diff --git a/pkg/schedule/schedulers/hot_region_config.go b/pkg/schedule/schedulers/hot_region_config.go index eebd5b50b6d..db833224978 100644 --- a/pkg/schedule/schedulers/hot_region_config.go +++ b/pkg/schedule/schedulers/hot_region_config.go @@ -85,6 +85,9 @@ func initHotRegionScheduleConfig() *hotRegionSchedulerConfig { func (conf *hotRegionSchedulerConfig) getValidConf() *hotRegionSchedulerConfig { return &hotRegionSchedulerConfig{ + baseDefaultSchedulerConfig: baseDefaultSchedulerConfig{ + Disabled: conf.Disabled, + }, MinHotByteRate: conf.MinHotByteRate, MinHotKeyRate: conf.MinHotKeyRate, MinHotQueryRate: conf.MinHotQueryRate, @@ -377,9 +380,13 @@ func (conf *hotRegionSchedulerConfig) ServeHTTP(w http.ResponseWriter, r *http.R } func (conf *hotRegionSchedulerConfig) handleGetConfig(w http.ResponseWriter, _ *http.Request) { + rd := render.New(render.Options{IndentJSON: true}) + + if conf.isDisable() { + rd.JSON(w, http.StatusNotFound, errs.ErrSchedulerNotFound.Error()) + } conf.RLock() defer conf.RUnlock() - rd := render.New(render.Options{IndentJSON: true}) rd.JSON(w, http.StatusOK, conf.getValidConf()) }