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

Remove duplicate error messages from cli commands #79493

Merged
merged 1 commit into from Jun 28, 2019

Conversation

@odinuge
Copy link
Member

commented Jun 27, 2019

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind bug

What this PR does / why we need it:
Since we never use the cobras "SilenceErrors" or "SilenceUsage",
a command executed with "cmd.Execute()" will never return an error
without printing it.

The current behavior results in all error messages being printed twice:

Example:

$ kubectl abc
Error: unknown command "abc" for "kubectl"
Run 'kubectl --help' for usage.
unknown command "abc" for "kubectl"

This applies to all cli commands using Cobra. To verify, follow the code
path of the Execute function:

https://github.com/spf13/cobra/blob/c439c4fa0937/command.go#L793

/sig cli

Which issue(s) this PR fixes:

Fixes #79454

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Fix duplicate error messages in cli commands
Remove duplicate error messages from cli commands
Since we never use the cobras "SilenceErrors" or "SilenceUsage",
a command executed with "cmd.Execute()" will never return an error
without printing it.

The current behavior results in all error messages being printed twice:

Example:

$ kubectl abc
Error: unknown command "abc" for "kubectl"
Run 'kubectl --help' for usage.
unknown command "abc" for "kubectl"

This applies to all cli commands using Cobra. To verify, follow the code
path of the Execute function:

https://github.com/spf13/cobra/blob/c439c4fa0937/command.go#L793
Signed-off-by: Odin Ugedal <odin@ugedal.com>
@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

commented Jun 27, 2019

Hi @odinuge. Thanks for your PR.

I'm waiting for a kubernetes 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. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@odinuge

This comment has been minimized.

Copy link
Member Author

commented Jun 27, 2019

@k8s-ci-robot k8s-ci-robot requested a review from BenTheElder Jun 27, 2019

@fedebongio

This comment has been minimized.

Copy link
Contributor

commented Jun 27, 2019

/assign @apelisse

@neolit123
Copy link
Member

left a comment

/lgtm
/approve
/ok-to-test

@k8s-ci-robot k8s-ci-robot added the lgtm label Jun 27, 2019

@neolit123

This comment has been minimized.

Copy link
Member

commented Jun 27, 2019

/priority backlog

@apelisse

This comment has been minimized.

Copy link
Member

commented Jun 27, 2019

OK It doesn't look like we're using SilenceErrors anywhere, so that should be fine. Also this output shouldn't be used by script so it shouldn't be a backward compatibility problem.

/lgtm
/approve

@odinuge

This comment has been minimized.

Copy link
Member Author

commented Jun 27, 2019

From cmd/OWNERS
/assign @thockin

😄

@odinuge

This comment has been minimized.

Copy link
Member Author

commented Jun 27, 2019

/test pull-kubernetes-dependencies

@BenTheElder

This comment has been minimized.

Copy link
Member

commented Jun 27, 2019

belated LGTM 🙃

@thockin
Copy link
Member

left a comment

Thanks!

/lgtm
/approve

@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

commented Jun 28, 2019

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: apelisse, neolit123, odinuge, thockin

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:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit dd8a000 into kubernetes:master Jun 28, 2019

23 checks passed

cla/linuxfoundation odinuge authorized
Details
pull-kubernetes-bazel-build Job succeeded.
Details
pull-kubernetes-bazel-test Job succeeded.
Details
pull-kubernetes-conformance-image-test Skipped.
pull-kubernetes-cross Skipped.
pull-kubernetes-dependencies Job succeeded.
Details
pull-kubernetes-e2e-gce Job succeeded.
Details
pull-kubernetes-e2e-gce-100-performance Job succeeded.
Details
pull-kubernetes-e2e-gce-csi-serial Skipped.
pull-kubernetes-e2e-gce-device-plugin-gpu Job succeeded.
Details
pull-kubernetes-e2e-gce-iscsi Skipped.
pull-kubernetes-e2e-gce-iscsi-serial Skipped.
pull-kubernetes-e2e-gce-storage-slow Skipped.
pull-kubernetes-godeps Skipped.
pull-kubernetes-integration Job succeeded.
Details
pull-kubernetes-kubemark-e2e-gce-big Job succeeded.
Details
pull-kubernetes-local-e2e Job succeeded.
Details
pull-kubernetes-node-e2e Job succeeded.
Details
pull-kubernetes-node-e2e-containerd Job succeeded.
Details
pull-kubernetes-typecheck Job succeeded.
Details
pull-kubernetes-verify Job succeeded.
Details
pull-publishing-bot-validate Skipped.
tide In merge pool.
Details
@odinuge

This comment has been minimized.

Copy link
Member Author

commented Jun 28, 2019

Is this something we want to cherry-pick into previous releases? The bug is quite annoying, and the fix is very simple..

Eg. this:

$ kubeadm ini
Error: unknown command "ini" for "kubeadm"

Did you mean this?
        init

Run 'kubeadm --help' for usage.
error: unknown command "ini" for "kubeadm"

Did you mean this?
        init
@BenTheElder

This comment has been minimized.

Copy link
Member

commented Jun 28, 2019

@odinuge good question, raised to #sig-release on slack 😅

@odinuge

This comment has been minimized.

Copy link
Member Author

commented Jun 28, 2019

Ahh, good idea! Didn't think about asking on slack 😄

@odinuge odinuge referenced this pull request Jul 1, 2019

Closed

REQUEST: New membership for odinuge #975

6 of 6 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.