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
operator: fix some error checks #5629
Conversation
Signed-off-by: HunDunDM <hundundm@gmail.com>
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
@@ -406,7 +406,7 @@ type PromoteLearner struct { | |||
// ConfVerChanged returns the delta value for version increased by this step. | |||
func (pl PromoteLearner) ConfVerChanged(region *core.RegionInfo) uint64 { | |||
peer := region.GetStoreVoter(pl.ToStore) | |||
return typeutil.BoolToUint64(peer.GetId() == pl.PeerID) | |||
return typeutil.BoolToUint64(peer.GetId() == pl.PeerID && peer.GetRole() == metapb.PeerRole_Voter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, IncomingVoter
and DemotingVoter
are also considered Voter
, so additional checks are required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should add these comments to code, which is convenient to read code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add some comment
func (dv DemoteVoter) ConfVerChanged(region *core.RegionInfo) bool { | ||
peer := region.GetStoreLearner(dv.ToStore) | ||
return peer.GetId() == dv.PeerID | ||
func (dv DemoteVoter) ConfVerChanged(region *core.RegionInfo) uint64 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ConfVerChanged
will be called when the next steps are performed, and it is necessary to consider that the Peer may have been removed in the future.
@@ -700,7 +701,8 @@ func (cpe ChangePeerV2Enter) ConfVerChanged(region *core.RegionInfo) uint64 { | |||
} | |||
} | |||
for _, dv := range cpe.DemoteVoters { | |||
peer := region.GetStoreVoter(dv.ToStore) | |||
peer := region.GetStorePeer(dv.ToStore) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There may be Learner
here, the previous GetStoreVoter
was used incorrectly.
@@ -715,16 +717,16 @@ func (cpe ChangePeerV2Enter) IsFinish(region *core.RegionInfo) bool { | |||
if peer != nil && peer.GetId() != pl.PeerID { | |||
log.Warn("obtain unexpected peer", zap.String("expect", pl.String()), zap.Uint64("obtain-voter", peer.GetId())) | |||
} | |||
if peer.GetId() != pl.PeerID || peer.GetRole() != metapb.PeerRole_IncomingVoter { | |||
if peer.GetId() != pl.PeerID || !core.IsVoterOrIncomingVoter(peer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow to promote directly.
@@ -740,12 +742,10 @@ func (cpe ChangePeerV2Enter) CheckInProgress(_ ClusterInformer, region *core.Reg | |||
return errors.New("peer does not exist") | |||
} | |||
switch peer.GetRole() { | |||
case metapb.PeerRole_Learner: | |||
case metapb.PeerRole_Learner, metapb.PeerRole_Voter: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow to promote directly.
Codecov ReportBase: 75.76% // Head: 75.65% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #5629 +/- ##
==========================================
- Coverage 75.76% 75.65% -0.12%
==========================================
Files 326 326
Lines 32386 32362 -24
==========================================
- Hits 24538 24484 -54
- Misses 5746 5770 +24
- Partials 2102 2108 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Signed-off-by: HunDunDM <hundundm@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it will impact the simulator?
/merge |
@nolouch: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
This pull request has been accepted and is ready to merge. Commit hash: d032e0b
|
@HunDunDM: Your PR was out of date, I have automatically updated it for you. At the same time I will also trigger all tests for you: /run-all-tests If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
does not affect |
What problem does this PR solve?
Issue Number: Close #5623
What is changed and how does it work?
PromoteLearner
andDemoteVoter
ChangePeerV2Enter
.Check List
Tests
Code changes
Side effects
Related changes
Release note