Skip to content

Commit

Permalink
adjust end evict scheduler func (#680)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaojingchen authored and weekface committed Jul 23, 2019
1 parent 41bceb5 commit 344a33a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pkg/pdapi/pdapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"sync"
"time"

"github.com/golang/glog"

"github.com/pingcap/kvproto/pkg/metapb"
"github.com/pingcap/kvproto/pkg/pdpb"
"github.com/pingcap/pd/pkg/typeutil"
Expand Down Expand Up @@ -472,9 +474,15 @@ func (pc *pdClient) EndEvictLeader(storeID uint64) error {
return err
}
defer httputil.DeferClose(res.Body)
if res.StatusCode == http.StatusOK || res.StatusCode == http.StatusNotFound {
if res.StatusCode == http.StatusNotFound {
return nil
}
if res.StatusCode == http.StatusOK {
glog.Infof("call DELETE method: %s success", apiURL)
} else {
err2 := httputil.ReadErrorBody(res.Body)
glog.Errorf("call DELETE method: %s failed,statusCode: %v,error: %v", apiURL, res.StatusCode, err2)
}

// pd will return an error with the body contains "scheduler not found" if the scheduler is not found
// this is not the standard response.
Expand All @@ -483,14 +491,13 @@ func (pc *pdClient) EndEvictLeader(storeID uint64) error {
// - return nil if the scheduler is not found
//
// when PD returns standard json response, we should get rid of this verbose code.
err2 := httputil.ReadErrorBody(res.Body)
evictLeaderSchedulers, err := pc.GetEvictLeaderSchedulers()
if err != nil {
return err
}
for _, s := range evictLeaderSchedulers {
if s == sName {
return fmt.Errorf("failed %v to end leader evict scheduler of store [%d], error: %v", res.StatusCode, storeID, err2)
return fmt.Errorf("end leader evict scheduler failed,the store:[%d]'s leader evict scheduler is still exist", storeID)
}
}

Expand Down

0 comments on commit 344a33a

Please sign in to comment.