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

fix pd_control: not rely on error text #197

Merged
merged 3 commits into from
Nov 29, 2018

Conversation

weekface
Copy link
Contributor

@weekface weekface commented Nov 26, 2018

  • just return an error if delete store failed
  • use GetEvictLeaderSchedulers instead

@tennix @xiaojingchen PTAL

@weekface
Copy link
Contributor Author

/run-e2e-tests

1 similar comment
@weekface
Copy link
Contributor Author

/run-e2e-tests

if strings.Contains(err2.Error(), schedulerExisted) {
return nil

evictLeaderSchedulers, err := pc.GetEvictLeaderSchedulers()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be exec before create evict leader, if the scheduler leader exists, then not need to post sheduler leader

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This replaces of strings.Contains, placed behind evicting leader is ok.

err2 := readErrorBody(res.Body)
if strings.Contains(err2.Error(), schedulerNotFound) {
return nil
evictLeaderSchedulers, err := pc.GetEvictLeaderSchedulers()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This replaces of strings.Contains, placed behind evicting leader is ok.

if strings.Contains(bodyStr, "store has been removed") {
return nil
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PD now actually returns a structured json response with an error code and an error code as a header.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but the older version don't have the error code and header.

Return the error is ok for this situation. The DeleteStore function is reentrant.

Copy link
Member

@tennix tennix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. But the code looks weird, especially the BeginEvictLeader and EndEvictLeader. Could you add a comment to say that this is a just a workaround for now, when PD returns standard json response, we should get rid of this verbose code.

@weekface
Copy link
Contributor Author

/run-e2e-tests

Copy link
Contributor

@xiaojingchen xiaojingchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@weekface
Copy link
Contributor Author

/run-e2e-tests

@tennix tennix merged commit 1bc6486 into pingcap:master Nov 29, 2018
@weekface weekface deleted the fix-pd-control branch November 29, 2018 11:18
queenliuxx pushed a commit to queenliuxx/tidb-operator that referenced this pull request Dec 19, 2018
yahonda pushed a commit that referenced this pull request Dec 27, 2021
Co-authored-by: Lilian Lee <lilin@pingcap.com>
fgksgf pushed a commit to fgksgf/tidb-operator that referenced this pull request Dec 23, 2024
Signed-off-by: liubo02 <liubo02@pingcap.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants