Bug 1778019

Summary: Usage info is being printed on all errors
Product: OpenShift Container Platform Reporter: Xingxing Xia <xxia>
Component: ocAssignee: Sally <somalley>
Status: CLOSED ERRATA QA Contact: zhou ying <yinzhou>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.3.0CC: aos-bugs, jokerman, mfojtik
Target Milestone: ---   
Target Release: 4.4.0   
Hardware: Unspecified   
OS: Unspecified   
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1748777 Environment:
Last Closed: 2020-05-04 11:17:52 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

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

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

  # Start a single instance of nginx.

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

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


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.