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

adjust end evict scheduler func #680

Merged
merged 2 commits into from
Jul 23, 2019
Merged
Changes from 1 commit
Commits
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
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