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

Etcd Cluster Downgrade #11362

Closed
wants to merge 25 commits into from
Closed

Etcd Cluster Downgrade #11362

wants to merge 25 commits into from

Conversation

YoyinZyc
Copy link
Contributor

@YoyinZyc YoyinZyc commented Nov 14, 2019

In this branch, @wenjiaswe and I added downgrade etcdctl command to control cluster to downgrade to one minor version lower. There are three new apis.

Future work

  • add downgrade status: check downgrade enabled and version of servers in the cluster
  • add downgrade timeout: If downgrade was never performed for some amount of time, target version (lower version) whitelisting will be revoked.

@wenjiaswe
Copy link
Contributor

Thanks @YoyinZyc for your work! @gyuho @xiang90 @jingyih @hexfusion Please help to take a look. Thanks!

@codecov-io
Copy link

codecov-io commented Nov 14, 2019

Codecov Report

Merging #11362 into master will increase coverage by 0.49%.
The diff coverage is 58.68%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #11362      +/-   ##
==========================================
+ Coverage   64.29%   64.79%   +0.49%     
==========================================
  Files         403      404       +1     
  Lines       38079    38751     +672     
==========================================
+ Hits        24484    25109     +625     
- Misses      11950    11988      +38     
- Partials     1645     1654       +9
Impacted Files Coverage Δ
etcdserver/api/v3rpc/rpctypes/error.go 90.47% <ø> (ø) ⬆️
etcdserver/api/v3rpc/util.go 67.74% <ø> (ø) ⬆️
etcdserver/errors.go 0% <ø> (ø) ⬆️
etcdctl/ctlv3/command/printer.go 0% <0%> (ø) ⬆️
etcdctl/ctlv3/command/printer_simple.go 0% <0%> (ø) ⬆️
etcdctl/ctlv3/command/printer_fields.go 0% <0%> (ø) ⬆️
etcdctl/ctlv3/ctl.go 100% <100%> (ø) ⬆️
etcdserver/api/capability.go 87.09% <100%> (ø) ⬆️
clientv3/retry.go 70.17% <100%> (+0.53%) ⬆️
proxy/grpcproxy/maintenance.go 51.21% <100%> (+3.85%) ⬆️
... and 37 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 fb7703a...22ddb23. Read the comment docs.


if d.Enabled && d.TargetVersion != nil {
oneMinorHigher := &semver.Version{Major: d.TargetVersion.Major, Minor: d.TargetVersion.Minor + 1}
if !lv.Equal(*d.TargetVersion) && !lv.Equal(*oneMinorHigher) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have a separate function with unit tests?

Something like isValidDowngrade(cur, target)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added isValidDowngrade(targetVersion, localVersion) and unit tests

}
}

if !d.Enabled && lv.LessThan(*cv) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's separate this part as well, to a separate function.

@jingyih
Copy link
Contributor

jingyih commented Nov 15, 2019

@gyuho
This is for etcd 3.5, do we still need to support plog in this PR?

Copy link
Contributor

@jingyih jingyih left a comment

Choose a reason for hiding this comment

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

I did a first pass. Overall approach looks good. I think we need to explore if there is a cleaner implementation on the part where individual server quires for cluster downgrade status during startup. Thanks for implementing this feature!

etcdserver/cluster_util.go Outdated Show resolved Hide resolved
etcdserver/v3_server.go Outdated Show resolved Hide resolved
etcdserver/api/membership/cluster.go Outdated Show resolved Hide resolved
etcdserver/api/membership/cluster.go Outdated Show resolved Hide resolved
etcdserver/api/membership/cluster.go Outdated Show resolved Hide resolved
etcdserver/cluster_util.go Outdated Show resolved Hide resolved
@gyuho
Copy link
Contributor

gyuho commented Nov 15, 2019

Yeah plog to be deprecated. No need to have them.

Copy link
Contributor

@jingyih jingyih left a comment

Choose a reason for hiding this comment

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

Reviewed the code path during server bootstrapping. Added few comments. PTAL:)

etcdserver/server.go Outdated Show resolved Hide resolved
etcdserver/server.go Outdated Show resolved Hide resolved
etcdserver/server.go Outdated Show resolved Hide resolved
etcdserver/server.go Outdated Show resolved Hide resolved
etcdserver/cluster_util.go Outdated Show resolved Hide resolved
etcdserver/cluster_util.go Outdated Show resolved Hide resolved
etcdserver/cluster_util.go Show resolved Hide resolved
etcdserver/v3_server.go Outdated Show resolved Hide resolved
Copy link
Contributor

@jingyih jingyih left a comment

Choose a reason for hiding this comment

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

Reviewed the server side implementation.

etcdserver/v3_server.go Outdated Show resolved Hide resolved
etcdserver/v3_server.go Show resolved Hide resolved
etcdserver/v3_server.go Outdated Show resolved Hide resolved
etcdserver/apply.go Outdated Show resolved Hide resolved
etcdserver/api/membership/store.go Outdated Show resolved Hide resolved
etcdserver/api/membership/store.go Outdated Show resolved Hide resolved
etcdserver/api/membership/store.go Outdated Show resolved Hide resolved
etcdserver/api/membership/cluster.go Outdated Show resolved Hide resolved
etcdserver/api/membership/cluster.go Show resolved Hide resolved
etcdserver/v3_server.go Show resolved Hide resolved
@YoyinZyc
Copy link
Contributor Author

Rebased the migration of cluster attributes.

Copy link
Contributor

@jingyih jingyih left a comment

Choose a reason for hiding this comment

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

I did a quick pass on the new code changes since rebasing. Overall looks good. I'll spend more time to review later.

}
resp.Version = cv.String()

allowedTargetVersion := semver.Version{Major: cv.Major, Minor: cv.Minor - 1}
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this work if current version is 4.0?

return nil, ErrIsNotDowngrading
}

raftRequest := membershippb.DowngradeInfoSetRequest{Enabled: false}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: If we set target version to 0 here, in apply stage we could simply reconstruct a new downgradeInfo from the request and overwrite the existing one.

@YoyinZyc
Copy link
Contributor Author

YoyinZyc commented Jan 2, 2020

@gyuho @jingyih @xiang90 @hexfusion Do you think this pr may be too big to review? I can divide it into smaller pr and collect more comments.

@gyuho
Copy link
Contributor

gyuho commented Jan 2, 2020

@YoyinZyc Yes please. Maybe one for adding a new RPC in server side. And another one for clientv3 change. And another one for etcdctl command changes?

@YoyinZyc YoyinZyc mentioned this pull request Jan 4, 2020
@YoyinZyc YoyinZyc mentioned this pull request Mar 23, 2020
13 tasks
@stale
Copy link

stale bot commented Apr 6, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 6, 2020
@wenjiaswe wenjiaswe removed the stale label Apr 7, 2020
@codecov-commenter
Copy link

Codecov Report

Merging #11362 into master will increase coverage by 0.16%.
The diff coverage is 58.68%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #11362      +/-   ##
==========================================
+ Coverage   64.62%   64.79%   +0.16%     
==========================================
  Files         403      404       +1     
  Lines       38079    38751     +672     
==========================================
+ Hits        24610    25109     +499     
- Misses      11838    11988     +150     
- Partials     1631     1654      +23     
Impacted Files Coverage Δ
etcdctl/ctlv3/command/printer.go 0.00% <0.00%> (ø)
etcdctl/ctlv3/command/printer_fields.go 0.00% <0.00%> (ø)
etcdctl/ctlv3/command/printer_simple.go 0.00% <0.00%> (ø)
etcdserver/api/v3rpc/rpctypes/error.go 90.47% <ø> (ø)
etcdserver/api/v3rpc/util.go 67.74% <ø> (ø)
etcdserver/errors.go 0.00% <ø> (ø)
etcdctl/ctlv3/command/downgrade_command.go 35.13% <35.13%> (ø)
etcdserver/api/membership/store.go 61.05% <46.39%> (-15.30%) ⬇️
etcdserver/server.go 66.58% <62.00%> (-1.40%) ⬇️
etcdserver/api/membership/cluster.go 75.74% <67.24%> (+2.96%) ⬆️
... and 34 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 378b05b...22ddb23. Read the comment docs.

@wenjiaswe
Copy link
Contributor

@YoyinZyc are you still working on this one, or is this split into smaller PRs?

@YoyinZyc
Copy link
Contributor Author

@YoyinZyc are you still working on this one, or is this split into smaller PRs?

Downgrade will be implemented with other smaller PRs. It is ok to mark this one as stale.

@stale
Copy link

stale bot commented Aug 26, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 26, 2020
@stale stale bot closed this Sep 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

6 participants