diff --git a/server/api/store.go b/server/api/store.go index 6a74ec77387..dec122e491a 100644 --- a/server/api/store.go +++ b/server/api/store.go @@ -368,8 +368,8 @@ func (h *storeHandler) SetLimit(w http.ResponseWriter, r *http.Request) { return } ratePerMin, ok := rateVal.(float64) - if !ok || ratePerMin < 0 { - h.rd.JSON(w, http.StatusBadRequest, "badformat rate") + if !ok || ratePerMin <= 0 { + h.rd.JSON(w, http.StatusBadRequest, "invalid rate which should be larger than 0") return } @@ -440,8 +440,8 @@ func (h *storesHandler) SetAllLimit(w http.ResponseWriter, r *http.Request) { return } ratePerMin, ok := rateVal.(float64) - if !ok || ratePerMin < 0 { - h.rd.JSON(w, http.StatusBadRequest, "badformat rate") + if !ok || ratePerMin <= 0 { + h.rd.JSON(w, http.StatusBadRequest, "invalid rate which should be larger than 0") return } diff --git a/tests/pdctl/store/store_test.go b/tests/pdctl/store/store_test.go index 19d79ef9c4a..a1501e21a94 100644 --- a/tests/pdctl/store/store_test.go +++ b/tests/pdctl/store/store_test.go @@ -196,6 +196,12 @@ func (s *storeTestSuite) TestStore(c *C) { limit2 = leaderServer.GetRaftCluster().GetStoreLimitByType(2, storelimit.RemovePeer) c.Assert(limit2, Equals, float64(25)) + // store limit all 0 + args = []string{"-u", pdAddr, "store", "limit", "all", "0"} + _, output, err = pdctl.ExecuteCommandC(cmd, args...) + c.Assert(err, IsNil) + c.Assert(strings.Contains(string(output), "invalid"), IsTrue) + // store limit echo := pdctl.GetEcho([]string{"-u", pdAddr, "store", "limit"}) allAddPeerLimit := make(map[string]map[string]interface{})