Skip to content

Commit

Permalink
fix ut TestSchedulerConfig
Browse files Browse the repository at this point in the history
Signed-off-by: okJiang <[email protected]>
  • Loading branch information
okJiang committed Aug 22, 2024
1 parent 551720c commit 58dc4f5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pkg/schedule/schedulers/balance_leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/schedule/schedulers/evict_slow_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down
9 changes: 8 additions & 1 deletion pkg/schedule/schedulers/hot_region_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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())
}

Expand Down

0 comments on commit 58dc4f5

Please sign in to comment.