Skip to content

raft: Forward-port improvements to campaign on restart#1589

Merged
aaronlehmann merged 1 commit into
moby:masterfrom
aaronlehmann:fix-campaign-on-restart-master
Oct 6, 2016
Merged

raft: Forward-port improvements to campaign on restart#1589
aaronlehmann merged 1 commit into
moby:masterfrom
aaronlehmann:fix-campaign-on-restart-master

Conversation

@aaronlehmann
Copy link
Copy Markdown
Collaborator

This brings the code on master in sync with the 1.12 changes in #1588. The code on master does not have the same problem (since a newer etcd/raft library lets it skip the problematic check), but the version being adopted by 1.12 should be a bit more robust.

This is a separate PR against master instead of cherry-picking from master to bump_v1.12.2 because the code has diverged and needs to be a bit different on master anyway (different etcd/raft version).

cc @LK4D4 @mrjana

@codecov-io
Copy link
Copy Markdown

codecov-io commented Sep 29, 2016

Current coverage is 54.08% (diff: 100%)

Merging #1589 into master will increase coverage by 0.21%

@@             master      #1589   diff @@
==========================================
  Files            84         84          
  Lines         13939      13848    -91   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
- Hits           7509       7490    -19   
+ Misses         5422       5357    -65   
+ Partials       1008       1001     -7   

Sunburst

Powered by Codecov. Last update ef26876...be79cc4

@aaronlehmann
Copy link
Copy Markdown
Collaborator Author

Passes Docker integration tests (except the ones that are normally flaky for me)

@LK4D4
Copy link
Copy Markdown
Contributor

LK4D4 commented Sep 29, 2016

@aaronlehmann I don't quite understand. Does this code needed at all in master?

@aaronlehmann
Copy link
Copy Markdown
Collaborator Author

I think it's more correct than the code that's on master right now. It may call Campaign too early, and the new version of etcd/raft automatically ignores that call. So we may have 5 second startup delays in rare cases. This PR should theoretically prevent that.

Comment thread manager/state/raft/raft.go Outdated
// Node ID should be in the progress list to Campaign
if len(n.cluster.Members()) <= 1 {
if n.campaignWhenAble && n.addedSelf {
if len(n.cluster.Members()) == 1 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this should just get n.cluster.Members() and check that sole member is self. Then you don't need addedSelf variable.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Hm. For some reason I thought there were situations where we could call n.cluster.AddMember() without actually applying a conf change in raft, but examining the code, I can't see any.

Updated. I'll update the 1.12 version as well.

// Node ID should be in the progress list to Campaign
if len(n.cluster.Members()) <= 1 {
if n.campaignWhenAble {
members := n.cluster.Members()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder why not just campaign once if you're sole member?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually, I see. Can you pls change comment, so it'll reflect that we start campaign also on inital cluster start?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Comment updated, thanks for noticing that.

This brings the code on master in sync with the 1.12 changes in moby#1588.
The code on master does not have the same problem (since a newer
etcd/raft library lets it skip the problematic check), but the version
being adopted by 1.12 should be a bit more robust.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
@aaronlehmann aaronlehmann force-pushed the fix-campaign-on-restart-master branch from 50921a9 to be79cc4 Compare September 30, 2016 19:56
@LK4D4
Copy link
Copy Markdown
Contributor

LK4D4 commented Sep 30, 2016

LGTM

Copy link
Copy Markdown
Member

@aluzzardi aluzzardi left a comment

Choose a reason for hiding this comment

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

LGTM

@aaronlehmann aaronlehmann merged commit 5eb9132 into moby:master Oct 6, 2016
@aaronlehmann aaronlehmann deleted the fix-campaign-on-restart-master branch October 6, 2016 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants