etcd-io / etcd

Distributed reliable key-value store for the most critical data of a distributed system
https://etcd.io
Apache License 2.0
47.5k stars 9.74k forks source link

Add examples to `etcdctl snapshot` command's help #18183

Closed ah8ad3 closed 1 month ago

ah8ad3 commented 3 months ago

Part of https://github.com/etcd-io/etcd/issues/17777. Add example section into etcdctl by first adding it to helper function of cobra. Create a util module into etcdctl move helper there. Add a normalizer function for exmaples. Change indent of etcdctl from "\t" to " ".

I tried to keep this PR simple and add only functionality of examples to helper and add examples of snapshot so it can be easy to review. /cc @ivanvc @jmhbnz

k8s-ci-robot commented 3 months ago

Hi @ah8ad3. Thanks for your PR.

I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
ah8ad3 commented 3 months ago

Im not sure about this test https://github.com/etcd-io/etcd/actions/runs/9534220896/job/26278395488?pr=18183

codecov-commenter commented 3 months ago

Codecov Report

Attention: Patch coverage is 53.29670% with 85 lines in your changes missing coverage. Please review.

Project coverage is 68.80%. Comparing base (d0ea231) to head (2de1500). Report is 120 commits behind head on main.

:exclamation: Current head 2de1500 differs from pull request most recent head a4b42c5

Please upload reports for the commit a4b42c5 to get more accurate results.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files | [Files](https://app.codecov.io/gh/etcd-io/etcd/pull/18183?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | | |---|---|---| | [server/config/config.go](https://app.codecov.io/gh/etcd-io/etcd/pull/18183?src=pr&el=tree&filepath=server%2Fconfig%2Fconfig.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c2VydmVyL2NvbmZpZy9jb25maWcuZ28=) | `79.76% <ø> (ø)` | | | [server/embed/config.go](https://app.codecov.io/gh/etcd-io/etcd/pull/18183?src=pr&el=tree&filepath=server%2Fembed%2Fconfig.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c2VydmVyL2VtYmVkL2NvbmZpZy5nbw==) | `78.95% <100.00%> (+0.84%)` | :arrow_up: | | [server/embed/etcd.go](https://app.codecov.io/gh/etcd-io/etcd/pull/18183?src=pr&el=tree&filepath=server%2Fembed%2Fetcd.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c2VydmVyL2VtYmVkL2V0Y2QuZ28=) | `75.52% <100.00%> (+0.17%)` | :arrow_up: | | [server/etcdmain/config.go](https://app.codecov.io/gh/etcd-io/etcd/pull/18183?src=pr&el=tree&filepath=server%2Fetcdmain%2Fconfig.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c2VydmVyL2V0Y2RtYWluL2NvbmZpZy5nbw==) | `64.39% <100.00%> (+0.82%)` | :arrow_up: | | [server/etcdserver/txn/metrics.go](https://app.codecov.io/gh/etcd-io/etcd/pull/18183?src=pr&el=tree&filepath=server%2Fetcdserver%2Ftxn%2Fmetrics.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c2VydmVyL2V0Y2RzZXJ2ZXIvdHhuL21ldHJpY3MuZ28=) | `100.00% <100.00%> (ø)` | | | [server/etcdserver/txn/txn.go](https://app.codecov.io/gh/etcd-io/etcd/pull/18183?src=pr&el=tree&filepath=server%2Fetcdserver%2Ftxn%2Ftxn.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c2VydmVyL2V0Y2RzZXJ2ZXIvdHhuL3R4bi5nbw==) | `93.15% <100.00%> (+0.06%)` | :arrow_up: | | [server/storage/mvcc/hash.go](https://app.codecov.io/gh/etcd-io/etcd/pull/18183?src=pr&el=tree&filepath=server%2Fstorage%2Fmvcc%2Fhash.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c2VydmVyL3N0b3JhZ2UvbXZjYy9oYXNoLmdv) | `100.00% <100.00%> (ø)` | | | [server/storage/mvcc/key\_index.go](https://app.codecov.io/gh/etcd-io/etcd/pull/18183?src=pr&el=tree&filepath=server%2Fstorage%2Fmvcc%2Fkey_index.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c2VydmVyL3N0b3JhZ2UvbXZjYy9rZXlfaW5kZXguZ28=) | `64.16% <ø> (ø)` | | | [server/storage/mvcc/kvstore.go](https://app.codecov.io/gh/etcd-io/etcd/pull/18183?src=pr&el=tree&filepath=server%2Fstorage%2Fmvcc%2Fkvstore.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c2VydmVyL3N0b3JhZ2UvbXZjYy9rdnN0b3JlLmdv) | `90.44% <100.00%> (ø)` | | | [server/storage/wal/metrics.go](https://app.codecov.io/gh/etcd-io/etcd/pull/18183?src=pr&el=tree&filepath=server%2Fstorage%2Fwal%2Fmetrics.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c2VydmVyL3N0b3JhZ2Uvd2FsL21ldHJpY3MuZ28=) | `100.00% <100.00%> (ø)` | | | ... and [15 more](https://app.codecov.io/gh/etcd-io/etcd/pull/18183?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | | ... and [30 files with indirect coverage changes](https://app.codecov.io/gh/etcd-io/etcd/pull/18183/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) ```diff @@ Coverage Diff @@ ## main #18183 +/- ## ========================================== - Coverage 69.01% 68.80% -0.22% ========================================== Files 415 417 +2 Lines 34963 35176 +213 ========================================== + Hits 24131 24202 +71 - Misses 9455 9555 +100 - Partials 1377 1419 +42 ``` ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/etcd-io/etcd/pull/18183?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/etcd-io/etcd/pull/18183?dropdown=coverage&src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None). Last update [d0ea231...a4b42c5](https://app.codecov.io/gh/etcd-io/etcd/pull/18183?dropdown=coverage&src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None).
ivanvc commented 3 months ago

Im not sure about this test https://github.com/etcd-io/etcd/actions/runs/9534220896/job/26278395488?pr=18183

I think you need to run a make fix and commit the changes to the go.mods, because you moved a file from pkg to etcdctl and didn't update the go.mod.

ah8ad3 commented 3 months ago

I think you need to run a make fix and commit the changes to the go.mods, because you moved a file from pkg to etcdctl and didn't update the go.mod.

I see what you mean, thanks that makes sense. I updated the code hopefully that will fix it.

ivanvc commented 3 months ago

Speaking of moving the file from pkg/cobrautil to etcdctl/util, why did you decide to do so? I'm not persuaded by this change, as if at some point we want to improve the help from other commands like etcdutl, it would make sense to move it back. Or maybe there's some reason why you moved it that is not clear to me.

ivanvc commented 3 months ago

/retitle Add examples to etcdctl snapshot command's help

ah8ad3 commented 3 months ago

Speaking of moving the file from pkg/cobrautil to etcdctl/util, why did you decide to do so? I'm not persuaded by this change, as if at some point we want to improve the help from other commands like etcdutl, it would make sense to move it back. Or maybe there's some reason why you moved it that is not clear to me.

As i understand this help file is only for etcdctl and not etcdutl and etcd commands, So it would make sense to move it to the etcdctl package. Also this helper is not well written, or maybe it was few years ago, we should change it to be more readable but i don't want to do that in this PR.

ah8ad3 commented 2 months ago

/remove-label area/*

k8s-ci-robot commented 2 months ago

@ah8ad3: The label(s) /remove-label area/* cannot be applied. These labels are supported: api-review, tide/merge-method-merge, tide/merge-method-rebase, tide/merge-method-squash, team/katacoda, refactor. Is this label configured under labels -> additional_labels or labels -> restricted_labels in plugin.yaml?

In response to [this](https://github.com/etcd-io/etcd/pull/18183#issuecomment-2244449510): >/remove-label area/* Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
ah8ad3 commented 2 months ago

Sorry, always happens to me when i rebase with wrong repository(forked one), tried to fix it. Let me know if should i do something. PTAL @jmhbnz

k8s-ci-robot commented 1 month ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ah8ad3, ahrtr, ivanvc, jmhbnz

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/etcd-io/etcd/blob/main/OWNERS)~~ [ahrtr,jmhbnz] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment