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

raft: fix restoring joint configurations #11003

Merged
merged 2 commits into from
Aug 9, 2019
Merged

Conversation

tbg
Copy link
Contributor

@tbg tbg commented Aug 7, 2019

While writing interaction tests for joint configuration changes, I realized
that this wasn't working yet - restoring had no notion of the joint
configuration and was simply dropping it on the floor.

This commit introduces a helper confchange.Restore which takes a
ConfState and initializes a Tracker from it.

This is then used both in (*raft).restore as well as in newRaft.

@tbg tbg requested a review from bdarnell August 7, 2019 16:52
tbg added a commit to tbg/etcd that referenced this pull request Aug 7, 2019
@codecov-io
Copy link

codecov-io commented Aug 7, 2019

Codecov Report

Merging #11003 into master will decrease coverage by 0.04%.
The diff coverage is 90.9%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #11003      +/-   ##
==========================================
- Coverage      64%   63.95%   -0.05%     
==========================================
  Files         401      402       +1     
  Lines       37581    37621      +40     
==========================================
+ Hits        24053    24061       +8     
- Misses      11916    11943      +27     
- Partials     1612     1617       +5
Impacted Files Coverage Δ
raft/tracker/tracker.go 96.87% <100%> (-0.27%) ⬇️
raft/confchange/confchange.go 81.28% <100%> (ø) ⬆️
raft/raft.go 90.17% <76.19%> (-0.52%) ⬇️
raft/util.go 69.44% <80%> (-2.44%) ⬇️
raft/confchange/restore.go 96.29% <96.29%> (ø)
client/client.go 42.81% <0%> (-41.18%) ⬇️
pkg/logutil/zap_grpc.go 47.61% <0%> (-4.77%) ⬇️
raft/tracker/inflights.go 91.83% <0%> (-4.09%) ⬇️
clientv3/leasing/kv.go 89.03% <0%> (-1.33%) ⬇️
... and 21 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7948f39...37ab5bd. Read the comment docs.

Copy link
Contributor

@nvanbenschoten nvanbenschoten left a comment

Choose a reason for hiding this comment

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

I'm planning on doing another pass tomorrow.

raft/raft.go Outdated

// applyConfChangePost is called from restore and applyConfChange to update any
Copy link
Contributor

Choose a reason for hiding this comment

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

"from newRaft, restore, and applyConfChange"

Also, I don't think you meant to say "update any updates". Did you mean process?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm also not in love with this name. It doesn't really tell me anything. It would be more effective if it mentioned what it does.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There was lots to not love about this. Now this method is in charge of actually setting the config. This turned out nicely I think, PTAL

}

// Restore takes a Changer (which must represent an empty configuration), and
// brings returns the state described by the supplied ConfState.
Copy link
Contributor

Choose a reason for hiding this comment

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

"brings returns"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


var ops []func(Changer) (tracker.Config, tracker.ProgressMap, error)

// First, apply all of the changes of the outgoing config one by one, so that
Copy link
Contributor

Choose a reason for hiding this comment

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

Move this into the if len(outgoing) > 0 { block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I also added additional commentary.

Copy link
Contributor Author

@tbg tbg left a comment

Choose a reason for hiding this comment

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

TFTR so far! Kept my new changes in new commits for easier reviewing (will squash them before merging). I did some more work documenting and testing, and also asserting in production code that the ConfState round trips successfully whenever we use Restore.

}

// Restore takes a Changer (which must represent an empty configuration), and
// brings returns the state described by the supplied ConfState.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


var ops []func(Changer) (tracker.Config, tracker.ProgressMap, error)

// First, apply all of the changes of the outgoing config one by one, so that
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I also added additional commentary.

raft/raft.go Outdated

// applyConfChangePost is called from restore and applyConfChange to update any
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There was lots to not love about this. Now this method is in charge of actually setting the config. This turned out nicely I think, PTAL

tbg added 2 commits August 9, 2019 19:28
While writing interaction tests for joint configuration changes, I
realized that this wasn't working yet - restoring had no notion of
the joint configuration and was simply dropping it on the floor.

This commit introduces a helper `confchange.Restore` which takes
a `ConfState` and initializes a `Tracker` from it.

This is then used both in `(*raft).restore` as well as in `newRaft`.
@tbg tbg merged commit 4cec8dd into etcd-io:master Aug 9, 2019
@tbg tbg deleted the interaction/restore branch August 9, 2019 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants