Bug 1778019 - Usage info is being printed on all errors
Summary: Usage info is being printed on all errors
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: oc
Version: 4.3.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: 4.4.0
Assignee: Sally
QA Contact: zhou ying
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-11-29 03:06 UTC by Xingxing Xia
Modified: 2020-05-04 11:18 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1748777
Environment:
Last Closed: 2020-05-04 11:17:52 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github openshift oc pull 234 0 None closed Bug 1778019: If required flag is not passed, don't print usage menu, only print error 2021-01-22 13:48:53 UTC
Red Hat Product Errata RHBA-2020:0581 0 None None None 2020-05-04 11:18:13 UTC

Description Xingxing Xia 2019-11-29 03:06:46 UTC
Happened to hit below:
oc run -aaaa
Error: unknown shorthand flag: 'a' in -aaaa
See 'oc run --help' for usage.

Now `oc run -aaaa` does not reproduce bug 1748777 and bug 1748777#c17 is indeed verified, found below cmds still print usage when hitting errors, though the first output line is enough:

oc run -lll
Error: required flag(s) "image" not set


Usage:
  oc run NAME --image=image [--env="key=value"] [--port=port] [--replicas=replicas] [--dry-run=bool] [--overrides=inline-json] [--command] -- [COMMAND] [args...] [flags]

Examples:
  # Start a single instance of nginx.
...

oc patch kubeapiserver/cluster
Error: required flag(s) "patch" not set


Usage:
  oc patch (-f FILENAME | TYPE NAME) -p PATCH [flags]

Examples:
...

oc version: openshift-clients-4.3.0-201911261917.git.1.133e54c.el7.x86_64

Comment 1 Maciej Szulik 2019-12-02 17:49:00 UTC
Sally can you check this, since you worked on https://bugzilla.redhat.com/show_bug.cgi?id=1748777
Moving this to 4.4, since it's a low priority item.

Comment 2 Sally 2019-12-05 20:01:31 UTC
For the 'oc run -lll' example, the output is expected, because the '-i' or '--image=' flag is required to run the command.  You passed 'oc run -lll' and that is actually a valid flag '-l=ll' or '--labels=ll', so you'll get the error for 'although a valid flag was passed, you did not give the required "image" flag.  I think returning usage in this case makes sense.  

For 'oc patch' the output is also expected, that the '-p' or '--patch=' flag must be set.  You passed 'oc patch type/name' but did not pass the "patch" flag like 'oc patch kubeapiserver/cluster -p blah'.  Since a 'bad flag' was not given, you still get the usage menu.  Again, I think returning usage makes sense here.

Comment 3 Sally 2019-12-13 14:34:08 UTC
After discussing with team, we'll want to only return the suggestion to run help, instead of the full menu.  I'll open a PR to this effect shortly.

Comment 6 Sally 2019-12-28 16:04:58 UTC
upstream PR here: https://github.com/kubernetes/kubernetes/pull/86693

Comment 8 zhou ying 2020-01-09 07:16:16 UTC
Confirmed with latest oc client, can't reproduce the issue now:

oc version: 4.4.0-202001081744.git.1.1aae263.el7

[root@dhcp-140-138 ~]# oc run -lll
Error: required flag(s) "image" not set


[root@dhcp-140-138 ~]# oc run -aa
Error: unknown shorthand flag: 'a' in -aa
See 'oc run --help' for usage.

Comment 10 errata-xmlrpc 2020-05-04 11:17:52 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:0581


Note You need to log in before you can comment on or make changes to this bug.