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 Downgrade] Store downgrade info to backend #11725

Merged
merged 1 commit into from
Apr 17, 2020

Conversation

YoyinZyc
Copy link
Contributor

Issue #11716

As a field of cluster, downgrade info is stored in backend.
This PR added the getter and setter of it.

@gyuho @jingyih

@YoyinZyc YoyinZyc mentioned this pull request Mar 26, 2020
13 tasks
@YoyinZyc
Copy link
Contributor Author

The failure test is flaky. They all got passed in my repo.
image

@YoyinZyc
Copy link
Contributor Author

YoyinZyc commented Apr 8, 2020

Friendly ping. @jingyih @gyuho Could you please have a look?:)

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.

Looks good in general. Thanks!

tx.UnsafePut(clusterBucketName, ckey, []byte(ver.String()))
tx.Unlock()
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason we changed line 75? In case UnsafePut fails, the deferred statement seems better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think there is only one line between Lock() and Unlock() so that it is not necessary to use defer()? If UnsafePut fails, why using defer is better?

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant if UnsafePut panics, defer ensures that the tx is unlocked.

Copy link
Contributor Author

@YoyinZyc YoyinZyc Apr 15, 2020

Choose a reason for hiding this comment

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

Understood. Changed to defer statement.

etcdserver/api/membership/cluster.go Outdated Show resolved Hide resolved
@codecov-io
Copy link

codecov-io commented Apr 14, 2020

Codecov Report

Merging #11725 into master will increase coverage by 0.19%.
The diff coverage is 11.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #11725      +/-   ##
==========================================
+ Coverage   66.49%   66.68%   +0.19%     
==========================================
  Files         403      403              
  Lines       36881    36935      +54     
==========================================
+ Hits        24524    24631     +107     
+ Misses      10855    10816      -39     
+ Partials     1502     1488      -14     
Impacted Files Coverage Δ
etcdserver/api/membership/cluster.go 78.01% <10.63%> (-6.79%) ⬇️
etcdserver/api/membership/store.go 55.46% <15.38%> (-5.22%) ⬇️
etcdserver/api/v3rpc/util.go 51.61% <0.00%> (-16.13%) ⬇️
clientv3/leasing/util.go 91.66% <0.00%> (-6.67%) ⬇️
clientv3/namespace/watch.go 87.87% <0.00%> (-6.07%) ⬇️
clientv3/leasing/cache.go 87.77% <0.00%> (-3.34%) ⬇️
clientv3/leasing/txn.go 88.09% <0.00%> (-3.18%) ⬇️
proxy/grpcproxy/watch.go 89.94% <0.00%> (-1.78%) ⬇️
clientv3/watch.go 90.18% <0.00%> (-1.05%) ⬇️
etcdserver/v3_server.go 74.68% <0.00%> (-0.86%) ⬇️
... and 12 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 1166b1f...f2c5dd4. Read the comment docs.

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.

Lgtm

type DowngradeInfo struct {
// TargetVersion is the target downgrade version, if the cluster is not under downgrading,
// the targetVersion will be an empty string
TargetVersion string
Copy link
Contributor

Choose a reason for hiding this comment

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

should we tag these fields rather than encoding them in camel case? e.g. json:"target-version"

Copy link
Contributor

@gyuho gyuho left a comment

Choose a reason for hiding this comment

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

lgtm, thx!

Let's update CHANGELOG in a separate PR.

@YoyinZyc
Copy link
Contributor Author

lgtm, thx!

Let's update CHANGELOG in a separate PR.

Thanks! I will update the CHANGELOG after finishing the server side of downgrade.

@gyuho gyuho merged commit 0908a8b into etcd-io:master Apr 17, 2020
@@ -691,6 +702,39 @@ func clusterVersionFromBackend(lg *zap.Logger, be backend.Backend) *semver.Versi
return semver.Must(semver.NewVersion(string(vals[0])))
}

func downgradeInfoFromBackend(lg *zap.Logger, be backend.Backend) *DowngradeInfo {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an unexported func without caller.

Can it be removed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The caller of this func will be added in following PRs. I want to put the getter and setter of downgradeInfo in one PR.

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.

5 participants