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

Refactor code to make place for downgrade logic #13391

Merged
merged 8 commits into from
Oct 8, 2021

Conversation

serathius
Copy link
Member

This PR collects set of refactors that are needed before implementing downgrade logic for #13168.
Refactors are split into multiple commits, reviewing one at the time should help with review process. Please let me know if it would make more sense to extract some commits into separate PR.

cc @ptabor, @lilic

@serathius serathius requested a review from ptabor October 6, 2021 15:08
@serathius serathius force-pushed the downgrade-refactor branch 2 times, most recently from a69e964 to 5e08bdf Compare October 7, 2021 10:43
Copy link
Contributor

@ptabor ptabor left a comment

Choose a reason for hiding this comment

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

Thank you. Just nits.

server/etcdserver/version/monitor_test.go Outdated Show resolved Hide resolved
server/etcdserver/version/version_test.go Outdated Show resolved Hide resolved
server/etcdserver/version/version.go Show resolved Hide resolved
Copy link
Contributor

@lilic lilic left a comment

Choose a reason for hiding this comment

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

Looking good, great work!

@@ -18,12 +18,13 @@ import (
"context"

"github.com/coreos/go-semver/semver"
pb "go.etcd.io/etcd/api/v3/etcdserverpb"
"go.etcd.io/etcd/api/v3/membershippb"
"go.etcd.io/etcd/server/v3/storage/backend"
"go.etcd.io/etcd/server/v3/storage/schema"
"go.uber.org/zap"

Copy link
Contributor

Choose a reason for hiding this comment

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

Small nit, lets group these by etcd internal and external packages. It's what some editors will auto change so we will see changes for this in the future.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea, hate that. I don't know good solution in Go for that. Python has isort https://github.com/PyCQA/isort that allows defining custom import blocks.


downgradeInfo := m.s.GetDowngradeInfo()
if downgradeInfo != nil && downgradeInfo.Enabled {
// Todo: return the downgrade status along with the error msg
Copy link
Contributor

Choose a reason for hiding this comment

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

This method only returns error, should we already make DowngradeValidate return something else in the signature so we don't change it later?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is old TODO taken from API call. Problem is that this error is passed to grpc server to decide what error code to return to cliuent. Problem is that currently it uses error -> rpc code map, which requires errors to be static (need to be a global variables), meaning that they cannot include information like downgrade status.

Fixing this issue would require to rewrite error handling logic for all requests, which is out of scope of this PR.

@ptabor ptabor merged commit 5b226e0 into etcd-io:main Oct 8, 2021
@serathius serathius deleted the downgrade-refactor branch June 15, 2023 20:39
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