-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
cli: Add etcdutl snapshot hashkv command #15965
Conversation
5eb6ff6
to
2b5fffb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @cenkalti.
Should we also add a quick segment of documentation to the README.md
at https://github.com/etcd-io/etcd/tree/main/etcdutl?
@jmhbnz Added. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - Thanks @cenkalti.
Note at some point I think we need to take some of the README.md
content and put together some overall human friendly documentation for etcdutl
on the website. Something similar to https://etcd.io/docs/v3.5/dev-guide/interacting_v3. Perhaps named Interacting with etcd data files
. A separate issue than this pr though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please resolve the review comments.
etcdutl/etcdutl/snapshot_command.go
Outdated
@@ -48,6 +49,7 @@ func NewSnapshotCommand() *cobra.Command { | |||
} | |||
cmd.AddCommand(NewSnapshotRestoreCommand()) | |||
cmd.AddCommand(newSnapshotStatusCommand()) | |||
cmd.AddCommand(newSnapshotHashKVCommand()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably it makes more sense to add a separate command something like etcdutl hashkv <filename> [flags]
, because it isn't necessary related to a snapshot.
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. |
/retest |
Hey @cenkalti - We highlighted this older pr during the sig-etcd triage meeting today. It would be great to get this tidied up and merged given we already had partial maintainer approval. Can you please rebase and address the remaining comments? Thanks! 🙏🏻 |
I'll do it this weekend. |
2de11cb
to
608d191
Compare
Rebased. Ready to merge. |
etcdutl/etcdutl/hashkv_command.go
Outdated
if len(args) != 1 { | ||
err := fmt.Errorf("hashkv requires exactly one argument") | ||
cobrautl.ExitWithError(cobrautl.ExitBadArgs, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest to use cobra.ExactArgs(1)
, but not a blocker to merge this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
We also need to add a changelog item, but it's OK to add it in a separate PR. cc @jmhbnz @ivanvc @ArkaSaha30 to take a second look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is looking good. I left two minor comments.
server/storage/mvcc/hash.go
Outdated
@@ -111,7 +111,7 @@ type hashStorage struct { | |||
lg *zap.Logger | |||
} | |||
|
|||
func newHashStorage(lg *zap.Logger, s *store) *hashStorage { | |||
func NewHashStorage(lg *zap.Logger, s *store) *hashStorage { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This (now) exported function returns an unexported struct. According to golangci-lint (and a linter rule we still need to enable), this is not a good practice. Refer to golang/lint#210.
However, HashStorage
is already defined as the interface. So, addressing this may require renaming either the interface or the struct 🤔. This may open a discussion rather than an immediate action item.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to return the interface.
etcdutl/etcdutl/hashkv_command.go
Outdated
CompactRevision int64 `json:"compactRevision"` | ||
} | ||
|
||
func calculateHashKV(dbPath string, rev int64) (ds HashKV, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I don't think this function benefits from defining named return values. ds
is not used, and err
is defined in line 70.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed return var names.
Signed-off-by: Cenk Alti <cenkalti@gmail.com> Apply suggestions from code review Co-authored-by: Benjamin Wang <benjamin.wang@broadcom.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks. Please also add a changelog item for 3.6 in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks, @cenkalti.
Fixes #15061