diff --git a/plugin/scheduler_example/evict_leader.go b/plugin/scheduler_example/evict_leader.go index b40633dfb2e..98c0abcfa25 100644 --- a/plugin/scheduler_example/evict_leader.go +++ b/plugin/scheduler_example/evict_leader.go @@ -260,7 +260,7 @@ func (handler *evictLeaderHandler) UpdateConfig(w http.ResponseWriter, r *http.R id = (uint64)(idFloat) if _, exists = handler.config.StoreIDWitRanges[id]; !exists { if err := handler.config.cluster.BlockStore(id); err != nil { - handler.rd.JSON(w, http.StatusInternalServerError, err) + handler.rd.JSON(w, http.StatusInternalServerError, err.Error()) return } } @@ -277,7 +277,7 @@ func (handler *evictLeaderHandler) UpdateConfig(w http.ResponseWriter, r *http.R handler.config.BuildWithArgs(args) err := handler.config.Persist() if err != nil { - handler.rd.JSON(w, http.StatusInternalServerError, err) + handler.rd.JSON(w, http.StatusInternalServerError, err.Error()) } handler.rd.JSON(w, http.StatusOK, nil) } @@ -314,7 +314,7 @@ func (handler *evictLeaderHandler) DeleteConfig(w http.ResponseWriter, r *http.R return } - handler.rd.JSON(w, http.StatusInternalServerError, errors.New("the config does not exist")) + handler.rd.JSON(w, http.StatusInternalServerError, errors.New("the config does not exist").Error()) } func newEvictLeaderHandler(config *evictLeaderSchedulerConfig) http.Handler { diff --git a/server/schedulers/evict_leader.go b/server/schedulers/evict_leader.go index de3028caee5..88d5cb0c516 100644 --- a/server/schedulers/evict_leader.go +++ b/server/schedulers/evict_leader.go @@ -299,7 +299,7 @@ func (handler *evictLeaderHandler) UpdateConfig(w http.ResponseWriter, r *http.R id = (uint64)(idFloat) if _, exists = handler.config.StoreIDWithRanges[id]; !exists { if err := handler.config.cluster.BlockStore(id); err != nil { - handler.rd.JSON(w, http.StatusInternalServerError, err) + handler.rd.JSON(w, http.StatusInternalServerError, err.Error()) return } } @@ -316,7 +316,7 @@ func (handler *evictLeaderHandler) UpdateConfig(w http.ResponseWriter, r *http.R handler.config.BuildWithArgs(args) err := handler.config.Persist() if err != nil { - handler.rd.JSON(w, http.StatusInternalServerError, err) + handler.rd.JSON(w, http.StatusInternalServerError, err.Error()) return } handler.rd.JSON(w, http.StatusOK, nil) @@ -340,15 +340,15 @@ func (handler *evictLeaderHandler) DeleteConfig(w http.ResponseWriter, r *http.R if succ { err = handler.config.Persist() if err != nil { - handler.rd.JSON(w, http.StatusInternalServerError, err) + handler.rd.JSON(w, http.StatusInternalServerError, err.Error()) return } if last { if err := handler.config.cluster.RemoveScheduler(EvictLeaderName); err != nil { if err == ErrSchedulerNotFound { - handler.rd.JSON(w, http.StatusNotFound, err) + handler.rd.JSON(w, http.StatusNotFound, err.Error()) } else { - handler.rd.JSON(w, http.StatusInternalServerError, err) + handler.rd.JSON(w, http.StatusInternalServerError, err.Error()) } return } @@ -358,7 +358,7 @@ func (handler *evictLeaderHandler) DeleteConfig(w http.ResponseWriter, r *http.R return } - handler.rd.JSON(w, http.StatusNotFound, ErrScheduleConfigNotExist) + handler.rd.JSON(w, http.StatusNotFound, ErrScheduleConfigNotExist.Error()) } func newEvictLeaderHandler(config *evictLeaderSchedulerConfig) http.Handler { diff --git a/server/schedulers/grant_leader.go b/server/schedulers/grant_leader.go index 30e117e6f3b..e8067163ecc 100644 --- a/server/schedulers/grant_leader.go +++ b/server/schedulers/grant_leader.go @@ -249,7 +249,7 @@ func (handler *grantLeaderHandler) UpdateConfig(w http.ResponseWriter, r *http.R id = (uint64)(idFloat) if _, exists = handler.config.StoreIDWithRanges[id]; !exists { if err := handler.config.cluster.BlockStore(id); err != nil { - handler.rd.JSON(w, http.StatusInternalServerError, err) + handler.rd.JSON(w, http.StatusInternalServerError, err.Error()) return } } @@ -266,7 +266,7 @@ func (handler *grantLeaderHandler) UpdateConfig(w http.ResponseWriter, r *http.R handler.config.BuildWithArgs(args) err := handler.config.Persist() if err != nil { - handler.rd.JSON(w, http.StatusInternalServerError, err) + handler.rd.JSON(w, http.StatusInternalServerError, err.Error()) return } handler.rd.JSON(w, http.StatusOK, nil) @@ -290,15 +290,15 @@ func (handler *grantLeaderHandler) DeleteConfig(w http.ResponseWriter, r *http.R if succ { err = handler.config.Persist() if err != nil { - handler.rd.JSON(w, http.StatusInternalServerError, err) + handler.rd.JSON(w, http.StatusInternalServerError, err.Error()) return } if last { if err := handler.config.cluster.RemoveScheduler(GrantLeaderName); err != nil { if err == ErrSchedulerNotFound { - handler.rd.JSON(w, http.StatusNotFound, err) + handler.rd.JSON(w, http.StatusNotFound, err.Error()) } else { - handler.rd.JSON(w, http.StatusInternalServerError, err) + handler.rd.JSON(w, http.StatusInternalServerError, err.Error()) } return } @@ -308,7 +308,7 @@ func (handler *grantLeaderHandler) DeleteConfig(w http.ResponseWriter, r *http.R return } - handler.rd.JSON(w, http.StatusNotFound, ErrScheduleConfigNotExist) + handler.rd.JSON(w, http.StatusNotFound, ErrScheduleConfigNotExist.Error()) } func newGrantLeaderHandler(config *grantLeaderSchedulerConfig) http.Handler { diff --git a/server/schedulers/scatter_range.go b/server/schedulers/scatter_range.go index ea08e5a00b0..f05a3b57600 100644 --- a/server/schedulers/scatter_range.go +++ b/server/schedulers/scatter_range.go @@ -237,7 +237,7 @@ func (handler *scatterRangeHandler) UpdateConfig(w http.ResponseWriter, r *http. name, ok := input["range-name"].(string) if ok { if name != handler.config.GetRangeName() { - handler.rd.JSON(w, http.StatusInternalServerError, errors.New("Cannot change the range name, please delete this schedule")) + handler.rd.JSON(w, http.StatusInternalServerError, errors.New("Cannot change the range name, please delete this schedule").Error()) return } args = append(args, name) @@ -261,7 +261,7 @@ func (handler *scatterRangeHandler) UpdateConfig(w http.ResponseWriter, r *http. handler.config.BuildWithArgs(args) err := handler.config.Persist() if err != nil { - handler.rd.JSON(w, http.StatusInternalServerError, err) + handler.rd.JSON(w, http.StatusInternalServerError, err.Error()) } handler.rd.JSON(w, http.StatusOK, nil) }