Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sche redirect9 1 #23

Closed
wants to merge 121 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
459671f
mcs: add timeout when call `alloc` of api server (#7254)
lhy1024 Oct 26, 2023
bfc988b
api: fix cannot dump trace (#7255)
nolouch Oct 26, 2023
4549e23
*: check whether region is nil (#7263)
lhy1024 Oct 26, 2023
89128f1
ctl: sort gc safepoint in pd-ctl (#7233)
bufferflies Oct 26, 2023
f9b476d
checker: add disconnected check when fix orphan peers (#7240)
lhy1024 Oct 26, 2023
cbdae92
mcs: support config http interface in scheduling server
lhy1024 Oct 26, 2023
42782d4
ci: run `make check` with longer timeout (#7271)
lhy1024 Oct 26, 2023
092ec86
test: make TestOperatorTestSuite more stable (#7268)
lhy1024 Oct 26, 2023
67ecd76
mcs: fix checkMembershipCh blocking (#7272)
lhy1024 Oct 27, 2023
744e51d
core: fix datarace in RegionsInfo (#7281)
lhy1024 Oct 27, 2023
ce0bb5d
mcs: support admin/cache http interface in scheduling server (#7279)
lhy1024 Oct 30, 2023
ded917b
config: fix `Clone` in `RatelimitConfig` (#7289)
CabinfeverB Oct 31, 2023
4e45e95
mcs: support scheduler config forward and enable some tests (#7256)
lhy1024 Nov 1, 2023
a1a1eea
resourcemanager: change param name (#7293)
CabinfeverB Nov 1, 2023
08927e5
Merge branch 'master' of github.com:tikv/pd into sche-redirect9
lhy1024 Nov 1, 2023
bd12406
move and fix test
lhy1024 Nov 1, 2023
6d28cd3
test_1
lhy1024 Nov 1, 2023
4baba6d
add more test
lhy1024 Nov 1, 2023
d83da71
test_2
lhy1024 Nov 1, 2023
5709e98
test_3
lhy1024 Nov 1, 2023
eac4ea0
test_4
lhy1024 Nov 1, 2023
64d83b2
test_5
lhy1024 Nov 1, 2023
366c4db
test_6
lhy1024 Nov 1, 2023
09bed12
test_7
lhy1024 Nov 1, 2023
27139cc
test_8
lhy1024 Nov 1, 2023
acc43bb
test_9
lhy1024 Nov 1, 2023
5217e9a
test_10
lhy1024 Nov 1, 2023
88771ae
test_11
lhy1024 Nov 1, 2023
1de5e12
test_12
lhy1024 Nov 1, 2023
4ea8f4c
test_13
lhy1024 Nov 1, 2023
ccb02db
test_14
lhy1024 Nov 1, 2023
e8f0185
test_15
lhy1024 Nov 1, 2023
1bf89d0
test_16
lhy1024 Nov 1, 2023
5ef862e
test_17
lhy1024 Nov 1, 2023
89c8be7
test_18
lhy1024 Nov 1, 2023
2aeb902
test_19
lhy1024 Nov 1, 2023
78b51f7
test_20
lhy1024 Nov 2, 2023
d965706
test_21
lhy1024 Nov 2, 2023
e12a9ce
test_22
lhy1024 Nov 2, 2023
dbc2e48
test_23
lhy1024 Nov 2, 2023
ccaf68b
test_24
lhy1024 Nov 2, 2023
5504cda
test_25
lhy1024 Nov 2, 2023
ff4241d
test_26
lhy1024 Nov 2, 2023
f2605e7
test_27
lhy1024 Nov 2, 2023
779133f
test_28
lhy1024 Nov 2, 2023
e3bf609
make test stable
lhy1024 Nov 2, 2023
4005db1
test_29
lhy1024 Nov 2, 2023
eb02dd5
Merge branch 'sche-redirect9' of github.com:lhy1024/pd into sche-redi…
lhy1024 Nov 2, 2023
4648f6f
test_1
lhy1024 Nov 2, 2023
9191326
test_2
lhy1024 Nov 2, 2023
90b93e9
test_3
lhy1024 Nov 2, 2023
5280c6e
test_4
lhy1024 Nov 2, 2023
9b08be0
test_5
lhy1024 Nov 2, 2023
a7d051c
test_6
lhy1024 Nov 2, 2023
802c236
test_7
lhy1024 Nov 2, 2023
d6c89cd
remove uncommon interfaces
lhy1024 Nov 2, 2023
d64d311
test_8
lhy1024 Nov 2, 2023
ab8bc53
fix
lhy1024 Nov 2, 2023
ab06849
fix lint
lhy1024 Nov 2, 2023
8849eef
Merge branch 'sche-redirect9' of github.com:lhy1024/pd into sche-redi…
lhy1024 Nov 2, 2023
ccd37e1
test_9
lhy1024 Nov 2, 2023
589cd80
test_10
lhy1024 Nov 2, 2023
dd2e3e5
test_11
lhy1024 Nov 2, 2023
c39f61c
test_12
lhy1024 Nov 2, 2023
d1788f6
test_13
lhy1024 Nov 2, 2023
343411f
test_14
lhy1024 Nov 2, 2023
b9cb9f1
test_15
lhy1024 Nov 2, 2023
37dd60f
test_16
lhy1024 Nov 2, 2023
d7987c6
test_17
lhy1024 Nov 2, 2023
9b7f06f
test_18
lhy1024 Nov 2, 2023
e770961
test_19
lhy1024 Nov 2, 2023
5ecb862
test_20
lhy1024 Nov 2, 2023
e5bd353
test_21
lhy1024 Nov 2, 2023
b748051
test_22
lhy1024 Nov 2, 2023
4418735
test_23
lhy1024 Nov 2, 2023
42b0ca2
test_24
lhy1024 Nov 2, 2023
9f9d2a7
test_25
lhy1024 Nov 2, 2023
41f35c2
make test stable
lhy1024 Nov 2, 2023
4ed3f04
Merge branch 'sche-redirect9' of github.com:lhy1024/pd into sche-redi…
lhy1024 Nov 2, 2023
035e20d
Merge branch 'sche-redirect9-1' of github.com:lhy1024/pd into sche-re…
lhy1024 Nov 2, 2023
cbfeb99
test_26
lhy1024 Nov 2, 2023
55537ea
test_27
lhy1024 Nov 2, 2023
df6fb93
test_28
lhy1024 Nov 2, 2023
49bebcf
test_29
lhy1024 Nov 2, 2023
24bd8f8
test_30
lhy1024 Nov 2, 2023
f9dfa89
test_31
lhy1024 Nov 2, 2023
d9266d6
test_32
lhy1024 Nov 2, 2023
795ecd6
test_33
lhy1024 Nov 2, 2023
2f35015
test_34
lhy1024 Nov 2, 2023
20a7057
test_35
lhy1024 Nov 2, 2023
587dcf4
test_36
lhy1024 Nov 2, 2023
58d42ff
test_37
lhy1024 Nov 2, 2023
d75e0c8
test_38
lhy1024 Nov 2, 2023
9828981
test_39
lhy1024 Nov 2, 2023
c31b0d9
test_40
lhy1024 Nov 2, 2023
d8ef237
test_41
lhy1024 Nov 2, 2023
1c07052
test_42
lhy1024 Nov 2, 2023
97bf7aa
test_43
lhy1024 Nov 2, 2023
f56f78c
test_44
lhy1024 Nov 2, 2023
9cbbe37
test_45
lhy1024 Nov 2, 2023
dea7a6b
test_46
lhy1024 Nov 2, 2023
ae99160
test_47
lhy1024 Nov 2, 2023
077c0f9
test_48
lhy1024 Nov 2, 2023
48feff3
test_49
lhy1024 Nov 2, 2023
23e883b
test_50
lhy1024 Nov 2, 2023
a7c1b73
test_51
lhy1024 Nov 2, 2023
f08e540
test_52
lhy1024 Nov 2, 2023
98840ac
test_53
lhy1024 Nov 2, 2023
b976d49
test_54
lhy1024 Nov 2, 2023
53982c6
test_55
lhy1024 Nov 2, 2023
118da11
test_56
lhy1024 Nov 2, 2023
9786aa3
test_57
lhy1024 Nov 2, 2023
e0202fa
test_58
lhy1024 Nov 2, 2023
4798d63
test_59
lhy1024 Nov 2, 2023
fa07113
test_60
lhy1024 Nov 3, 2023
30e09fa
test_61
lhy1024 Nov 3, 2023
39c25a7
test_62
lhy1024 Nov 3, 2023
580ba58
test_63
lhy1024 Nov 3, 2023
09f5f67
test_64
lhy1024 Nov 3, 2023
c37afc6
test_65
lhy1024 Nov 3, 2023
87b4463
test_66
lhy1024 Nov 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ concurrency:
jobs:
statics:
runs-on: ubuntu-latest
timeout-minutes: 10
timeout-minutes: 20
steps:
- uses: actions/setup-go@v3
with:
Expand Down
10 changes: 10 additions & 0 deletions errors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,16 @@ error = '''
init file log error, %s
'''

["PD:mcs:ErrNotFoundSchedulingAddr"]
error = '''
cannot find scheduling address
'''

["PD:mcs:ErrSchedulingServer"]
error = '''
scheduling server meets %v
'''

["PD:member:ErrCheckCampaign"]
error = '''
check campaign failed
Expand Down
4 changes: 2 additions & 2 deletions pkg/core/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -1339,8 +1339,8 @@ func (r *RegionsInfo) GetStoreWriteRate(storeID uint64) (bytesRate, keysRate flo

// GetClusterNotFromStorageRegionsCnt gets the total count of regions that not loaded from storage anymore
func (r *RegionsInfo) GetClusterNotFromStorageRegionsCnt() int {
r.st.RLock()
defer r.st.RUnlock()
r.t.RLock()
defer r.t.RUnlock()
return r.tree.notFromStorageRegionsCnt
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/errs/errno.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,3 +403,9 @@ var (
ErrDeleteReservedGroup = errors.Normalize("cannot delete reserved group", errors.RFCCodeText("PD:resourcemanager:ErrDeleteReservedGroup"))
ErrInvalidGroup = errors.Normalize("invalid group settings, please check the group name, priority and the number of resources", errors.RFCCodeText("PD:resourcemanager:ErrInvalidGroup"))
)

// Micro service errors
var (
ErrNotFoundSchedulingAddr = errors.Normalize("cannot find scheduling address", errors.RFCCodeText("PD:mcs:ErrNotFoundSchedulingAddr"))
ErrSchedulingServer = errors.Normalize("scheduling server meets %v", errors.RFCCodeText("PD:mcs:ErrSchedulingServer"))
)
4 changes: 2 additions & 2 deletions pkg/mcs/resourcemanager/server/resource_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func FromProtoResourceGroup(group *rmpb.ResourceGroup) *ResourceGroup {
// RequestRU requests the RU of the resource group.
func (rg *ResourceGroup) RequestRU(
now time.Time,
neededTokens float64,
requiredToken float64,
targetPeriodMs, clientUniqueID uint64,
) *rmpb.GrantedRUTokenBucket {
rg.Lock()
Expand All @@ -147,7 +147,7 @@ func (rg *ResourceGroup) RequestRU(
if rg.RUSettings == nil || rg.RUSettings.RU.Settings == nil {
return nil
}
tb, trickleTimeMs := rg.RUSettings.RU.request(now, neededTokens, targetPeriodMs, clientUniqueID)
tb, trickleTimeMs := rg.RUSettings.RU.request(now, requiredToken, targetPeriodMs, clientUniqueID)
return &rmpb.GrantedRUTokenBucket{GrantedTokens: tb, TrickleTimeMs: trickleTimeMs}
}

Expand Down
42 changes: 21 additions & 21 deletions pkg/mcs/resourcemanager/server/token_buckets.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func (gtb *GroupTokenBucket) init(now time.Time, clientID uint64) {
}

// updateTokens updates the tokens and settings.
func (gtb *GroupTokenBucket) updateTokens(now time.Time, burstLimit int64, clientUniqueID uint64, consumptionToken float64) {
func (gtb *GroupTokenBucket) updateTokens(now time.Time, burstLimit int64, clientUniqueID uint64, requiredToken float64) {
var elapseTokens float64
if !gtb.Initialized {
gtb.init(now, clientUniqueID)
Expand All @@ -288,46 +288,46 @@ func (gtb *GroupTokenBucket) updateTokens(now time.Time, burstLimit int64, clien
gtb.Tokens = burst
}
// Balance each slots.
gtb.balanceSlotTokens(clientUniqueID, gtb.Settings, consumptionToken, elapseTokens)
gtb.balanceSlotTokens(clientUniqueID, gtb.Settings, requiredToken, elapseTokens)
}

// request requests tokens from the corresponding slot.
func (gtb *GroupTokenBucket) request(now time.Time,
neededTokens float64,
requiredToken float64,
targetPeriodMs, clientUniqueID uint64,
) (*rmpb.TokenBucket, int64) {
burstLimit := gtb.Settings.GetBurstLimit()
gtb.updateTokens(now, burstLimit, clientUniqueID, neededTokens)
gtb.updateTokens(now, burstLimit, clientUniqueID, requiredToken)
slot, ok := gtb.tokenSlots[clientUniqueID]
if !ok {
return &rmpb.TokenBucket{Settings: &rmpb.TokenLimitSettings{BurstLimit: burstLimit}}, 0
}
res, trickleDuration := slot.assignSlotTokens(neededTokens, targetPeriodMs)
res, trickleDuration := slot.assignSlotTokens(requiredToken, targetPeriodMs)
// Update bucket to record all tokens.
gtb.Tokens -= slot.lastTokenCapacity - slot.tokenCapacity
slot.lastTokenCapacity = slot.tokenCapacity

return res, trickleDuration
}

func (ts *TokenSlot) assignSlotTokens(neededTokens float64, targetPeriodMs uint64) (*rmpb.TokenBucket, int64) {
func (ts *TokenSlot) assignSlotTokens(requiredToken float64, targetPeriodMs uint64) (*rmpb.TokenBucket, int64) {
var res rmpb.TokenBucket
burstLimit := ts.settings.GetBurstLimit()
res.Settings = &rmpb.TokenLimitSettings{BurstLimit: burstLimit}
// If BurstLimit < 0, just return.
if burstLimit < 0 {
res.Tokens = neededTokens
res.Tokens = requiredToken
return &res, 0
}
// FillRate is used for the token server unavailable in abnormal situation.
if neededTokens <= 0 {
if requiredToken <= 0 {
return &res, 0
}
// If the current tokens can directly meet the requirement, returns the need token.
if ts.tokenCapacity >= neededTokens {
ts.tokenCapacity -= neededTokens
if ts.tokenCapacity >= requiredToken {
ts.tokenCapacity -= requiredToken
// granted the total request tokens
res.Tokens = neededTokens
res.Tokens = requiredToken
return &res, 0
}

Expand All @@ -336,7 +336,7 @@ func (ts *TokenSlot) assignSlotTokens(neededTokens float64, targetPeriodMs uint6
hasRemaining := false
if ts.tokenCapacity > 0 {
grantedTokens = ts.tokenCapacity
neededTokens -= grantedTokens
requiredToken -= grantedTokens
ts.tokenCapacity = 0
hasRemaining = true
}
Expand Down Expand Up @@ -373,36 +373,36 @@ func (ts *TokenSlot) assignSlotTokens(neededTokens float64, targetPeriodMs uint6
for i := 1; i < loanCoefficient; i++ {
p[i] = float64(loanCoefficient-i)*float64(fillRate)*targetPeriodTimeSec + p[i-1]
}
for i := 0; i < loanCoefficient && neededTokens > 0 && trickleTime < targetPeriodTimeSec; i++ {
for i := 0; i < loanCoefficient && requiredToken > 0 && trickleTime < targetPeriodTimeSec; i++ {
loan := -ts.tokenCapacity
if loan >= p[i] {
continue
}
roundReserveTokens := p[i] - loan
fillRate := float64(loanCoefficient-i) * float64(fillRate)
if roundReserveTokens > neededTokens {
ts.tokenCapacity -= neededTokens
grantedTokens += neededTokens
if roundReserveTokens > requiredToken {
ts.tokenCapacity -= requiredToken
grantedTokens += requiredToken
trickleTime += grantedTokens / fillRate
neededTokens = 0
requiredToken = 0
} else {
roundReserveTime := roundReserveTokens / fillRate
if roundReserveTime+trickleTime >= targetPeriodTimeSec {
roundTokens := (targetPeriodTimeSec - trickleTime) * fillRate
neededTokens -= roundTokens
requiredToken -= roundTokens
ts.tokenCapacity -= roundTokens
grantedTokens += roundTokens
trickleTime = targetPeriodTimeSec
} else {
grantedTokens += roundReserveTokens
neededTokens -= roundReserveTokens
requiredToken -= roundReserveTokens
ts.tokenCapacity -= roundReserveTokens
trickleTime += roundReserveTime
}
}
}
if neededTokens > 0 && grantedTokens < defaultReserveRatio*float64(fillRate)*targetPeriodTimeSec {
reservedTokens := math.Min(neededTokens+grantedTokens, defaultReserveRatio*float64(fillRate)*targetPeriodTimeSec)
if requiredToken > 0 && grantedTokens < defaultReserveRatio*float64(fillRate)*targetPeriodTimeSec {
reservedTokens := math.Min(requiredToken+grantedTokens, defaultReserveRatio*float64(fillRate)*targetPeriodTimeSec)
ts.tokenCapacity -= reservedTokens - grantedTokens
grantedTokens = reservedTokens
}
Expand Down
127 changes: 125 additions & 2 deletions pkg/mcs/scheduling/server/apis/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package apis

import (
"fmt"
"net/http"
"strconv"
"sync"
Expand All @@ -26,11 +25,13 @@ import (
"github.com/gin-gonic/gin"
"github.com/joho/godotenv"
"github.com/pingcap/log"
"github.com/tikv/pd/pkg/errs"
scheserver "github.com/tikv/pd/pkg/mcs/scheduling/server"
mcsutils "github.com/tikv/pd/pkg/mcs/utils"
sche "github.com/tikv/pd/pkg/schedule/core"
"github.com/tikv/pd/pkg/schedule/handler"
"github.com/tikv/pd/pkg/schedule/operator"
"github.com/tikv/pd/pkg/schedule/schedulers"
"github.com/tikv/pd/pkg/statistics/utils"
"github.com/tikv/pd/pkg/storage"
"github.com/tikv/pd/pkg/utils/apiutil"
Expand Down Expand Up @@ -110,6 +111,7 @@ func NewService(srv *scheserver.Service) *Service {
rd: createIndentRender(),
}
s.RegisterAdminRouter()
s.RegisterConfigRouter()
s.RegisterOperatorsRouter()
s.RegisterSchedulersRouter()
s.RegisterCheckersRouter()
Expand All @@ -121,13 +123,23 @@ func NewService(srv *scheserver.Service) *Service {
func (s *Service) RegisterAdminRouter() {
router := s.root.Group("admin")
router.PUT("/log", changeLogLevel)
router.DELETE("cache/regions", deleteAllRegionCache)
router.DELETE("cache/regions/:id", deleteRegionCacheByID)
}

// RegisterConfigRouter registers the router of the config handler.
func (s *Service) RegisterConfigRouter() {
router := s.root.Group("config")
router.GET("", getConfig)
}

// RegisterSchedulersRouter registers the router of the schedulers handler.
func (s *Service) RegisterSchedulersRouter() {
router := s.root.Group("schedulers")
router.GET("", getSchedulers)
router.GET("/diagnostic/:name", getDiagnosticResult)
router.GET("/config", getSchedulerConfig)
router.GET("/config/:name/list", getSchedulerConfigByName)
// TODO: in the future, we should split pauseOrResumeScheduler to two different APIs.
// And we need to do one-to-two forwarding in the API middleware.
router.POST("/:name", pauseOrResumeScheduler)
Expand Down Expand Up @@ -160,6 +172,11 @@ func (s *Service) RegisterOperatorsRouter() {
router.GET("/records", getOperatorRecords)
}

// @Tags admin
// @Summary Change the log level.
// @Produce json
// @Success 200 {string} string "The log level is updated."
// @Router /admin/log [put]
func changeLogLevel(c *gin.Context) {
svr := c.MustGet(multiservicesapi.ServiceContextKey).(*scheserver.Server)
var level string
Expand All @@ -176,6 +193,58 @@ func changeLogLevel(c *gin.Context) {
c.String(http.StatusOK, "The log level is updated.")
}

// @Tags config
// @Summary Get full config.
// @Produce json
// @Success 200 {object} config.Config
// @Router /config [get]
func getConfig(c *gin.Context) {
svr := c.MustGet(multiservicesapi.ServiceContextKey).(*scheserver.Server)
cfg := svr.GetConfig()
cfg.Schedule.MaxMergeRegionKeys = cfg.Schedule.GetMaxMergeRegionKeys()
c.IndentedJSON(http.StatusOK, cfg)
}

// @Tags admin
// @Summary Drop all regions from cache.
// @Produce json
// @Success 200 {string} string "All regions are removed from server cache."
// @Router /admin/cache/regions [delete]
func deleteAllRegionCache(c *gin.Context) {
svr := c.MustGet(multiservicesapi.ServiceContextKey).(*scheserver.Server)
cluster := svr.GetCluster()
if cluster == nil {
c.String(http.StatusInternalServerError, errs.ErrNotBootstrapped.GenWithStackByArgs().Error())
return
}
cluster.DropCacheAllRegion()
c.String(http.StatusOK, "All regions are removed from server cache.")
}

// @Tags admin
// @Summary Drop a specific region from cache.
// @Param id path integer true "Region Id"
// @Produce json
// @Success 200 {string} string "The region is removed from server cache."
// @Failure 400 {string} string "The input is invalid."
// @Router /admin/cache/regions/{id} [delete]
func deleteRegionCacheByID(c *gin.Context) {
svr := c.MustGet(multiservicesapi.ServiceContextKey).(*scheserver.Server)
cluster := svr.GetCluster()
if cluster == nil {
c.String(http.StatusInternalServerError, errs.ErrNotBootstrapped.GenWithStackByArgs().Error())
return
}
regionIDStr := c.Param("id")
regionID, err := strconv.ParseUint(regionIDStr, 10, 64)
if err != nil {
c.String(http.StatusBadRequest, err.Error())
return
}
cluster.DropCacheRegion(regionID)
c.String(http.StatusOK, "The region is removed from server cache.")
}

// @Tags operators
// @Summary Get an operator by ID.
// @Param region_id path int true "A Region's Id"
Expand Down Expand Up @@ -385,6 +454,60 @@ func getSchedulers(c *gin.Context) {
c.IndentedJSON(http.StatusOK, output)
}

// @Tags schedulers
// @Summary List all scheduler configs.
// @Produce json
// @Success 200 {object} map[string]interface{}
// @Failure 500 {string} string "PD server failed to proceed the request."
// @Router /schedulers/config/ [get]
func getSchedulerConfig(c *gin.Context) {
handler := c.MustGet(handlerKey).(*handler.Handler)
sc, err := handler.GetSchedulersController()
if err != nil {
c.String(http.StatusInternalServerError, err.Error())
return
}
sches, configs, err := sc.GetAllSchedulerConfigs()
if err != nil {
c.String(http.StatusInternalServerError, err.Error())
return
}
c.IndentedJSON(http.StatusOK, schedulers.ToPayload(sches, configs))
}

// @Tags schedulers
// @Summary List scheduler config by name.
// @Produce json
// @Success 200 {object} map[string]interface{}
// @Failure 404 {string} string scheduler not found
// @Failure 500 {string} string "PD server failed to proceed the request."
// @Router /schedulers/config/{name}/list [get]
func getSchedulerConfigByName(c *gin.Context) {
handler := c.MustGet(handlerKey).(*handler.Handler)
sc, err := handler.GetSchedulersController()
if err != nil {
c.String(http.StatusInternalServerError, err.Error())
return
}
handlers := sc.GetSchedulerHandlers()
name := c.Param("name")
if _, ok := handlers[name]; !ok {
c.String(http.StatusNotFound, errs.ErrSchedulerNotFound.GenWithStackByArgs().Error())
return
}
isDisabled, err := sc.IsSchedulerDisabled(name)
if err != nil {
c.String(http.StatusInternalServerError, err.Error())
return
}
if isDisabled {
c.String(http.StatusNotFound, errs.ErrSchedulerNotFound.GenWithStackByArgs().Error())
return
}
c.Request.URL.Path = "/list"
handlers[name].ServeHTTP(c.Writer, c.Request)
}

// @Tags schedulers
// @Summary List schedulers diagnostic result.
// @Produce json
Expand Down Expand Up @@ -475,7 +598,7 @@ func getHotRegions(typ utils.RWType, c *gin.Context) {
for _, storeID := range storeIDs {
id, err := strconv.ParseUint(storeID, 10, 64)
if err != nil {
c.String(http.StatusBadRequest, fmt.Sprintf("invalid store id: %s", storeID))
c.String(http.StatusBadRequest, errs.ErrInvalidStoreID.FastGenByArgs(storeID).Error())
return
}
_, err = handler.GetStore(id)
Expand Down
Loading
Loading