Skip to content

Commit 344a33a

Browse files
xiaojingchenweekface
authored andcommitted
adjust end evict scheduler func (#680)
1 parent 41bceb5 commit 344a33a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

pkg/pdapi/pdapi.go

+10-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import (
2323
"sync"
2424
"time"
2525

26+
"github.com/golang/glog"
27+
2628
"github.com/pingcap/kvproto/pkg/metapb"
2729
"github.com/pingcap/kvproto/pkg/pdpb"
2830
"github.com/pingcap/pd/pkg/typeutil"
@@ -472,9 +474,15 @@ func (pc *pdClient) EndEvictLeader(storeID uint64) error {
472474
return err
473475
}
474476
defer httputil.DeferClose(res.Body)
475-
if res.StatusCode == http.StatusOK || res.StatusCode == http.StatusNotFound {
477+
if res.StatusCode == http.StatusNotFound {
476478
return nil
477479
}
480+
if res.StatusCode == http.StatusOK {
481+
glog.Infof("call DELETE method: %s success", apiURL)
482+
} else {
483+
err2 := httputil.ReadErrorBody(res.Body)
484+
glog.Errorf("call DELETE method: %s failed,statusCode: %v,error: %v", apiURL, res.StatusCode, err2)
485+
}
478486

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

0 commit comments

Comments
 (0)