Bug 1387575

Summary: [userinterface_public_711] Message from oadm with --request-timeout needs not the info of help cmd
Product: OKD Reporter: Xingxing Xia <xxia>
Component: ocAssignee: Juan Vallejo <jvallejo>
Status: CLOSED CURRENTRELEASE QA Contact: Xingxing Xia <xxia>
Severity: low Docs Contact:
Priority: low    
Version: 3.xCC: aos-bugs, mmccomas
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-11-10 21:34:11 UTC Type: Bug
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 2016-10-21 10:08:54 UTC
Description of problem:
Message from oadm (or oc adm) with --request-timeout needs not the info of help cmd.
Message from oc with --request-timeout just has no that info, except `oc adm`.

Version-Release number of selected component (if applicable):
openshift/oc v1.4.0-alpha.0+28ae87f

How reproducible:
Always

Steps to Reproduce:
1. $ oc get pod --request-timeout=1ms
2. $ oadm policy remove-role-from-user admin star --request-timeout=1ms
3.

Actual results:
Both oc and oadm can shows the timeout info:
error: Get https://<master>:8443/api: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

But oadm has one extra line: See 'oadm ... -h' for help and examples.

Expected results:
That help cmd info is not related to timeout error and thus not needed.

Additional info:

Comment 1 Juan Vallejo 2016-10-21 20:42:52 UTC
The reason why you are seeing this additional error (See 'oadm ... -h' ...) after _some_ `oadm` sub-commands is because they pass any errors they receive through  CheckErr(UsageErr(err)) https://github.com/openshift/origin/blob/master/pkg/cmd/admin/policy/modify_roles.go#L137

This is not limited to just `oadm` commands, several `oc` commands such as `oc policy` do this as well:

```
$ oc policy can-i list pods --request-timeout=1ms
error: Get https://10.13.137.149:8443/api: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
See 'oc policy can-i -h' for help and examples.
```

A solution to this would be to type the request timeout error, go through every  sub-command in the command tree that returns a `UsageError` on failure, and update it so that the `UsageError` is returned in each of its helper functions instead (but only if the error is not of the new request timeout error type), rather than having the UsageError return in the command's `Run` function. I am not sure how feasible this would be.

Comment 2 Juan Vallejo 2017-10-26 15:59:24 UTC
At least as of v3.7, executing the command from comment 0 [1] no longer displays help info:

[1]
```
$ oadm policy remove-role-from-user admin star --request-timeout=1ms
Unable to connect to the server: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
```

Comment 3 Xingxing Xia 2017-10-27 09:49:52 UTC
Indeed in v3.7 (oadm v3.7.0-0.181.0) the unrelated "See 'oadm ... -h' for help and examples" is not shown. (oadm v3.6.173.0.56 still shows)