Bug 1501756

Summary: [Trello o6UiTkxv] Exit code from oc plugin does not return to bash terminal
Product: OpenShift Container Platform Reporter: XiaochuanWang <xiaocwan>
Component: ocAssignee: Maciej Szulik <maszulik>
Status: CLOSED ERRATA QA Contact: Xingxing Xia <xxia>
Severity: low Docs Contact:
Priority: medium    
Version: 3.7.0CC: aos-bugs, jokerman, mmccomas
Target Milestone: ---Keywords: Rebase
Target Release: 3.9.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: Error code was not properly propagated from plugin. Consequence: oc plugin was not returning error when it should. Fix: Properly propagate errors from plugins. Result: Error code matches result.
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-03-13 22:27:23 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:
Embargoed:

Description XiaochuanWang 2017-10-13 06:53:36 UTC
Description of problem:
Create a oc plugin with negative command, exec the oc plugin command and check exit code again on terminal, exit code is not correct.

Version-Release number of selected component (if applicable):
oc v3.7.0-0.147.1

How reproducible:
Always

Steps to Reproduce:
1. # mkdir -p /usr/share/kubectl/plugins/myplugin
2. # vi /usr/share/kubectl/plugins/myplugin/plugin.yaml
name: "myplugin"
shortDesc: "My plugin's short description"
command: "ls non-existed"
3. # oc plugin myplugin
4. check exit code by echo $?

Actual results:
3. ls: cannot access non-existed: No such file or directory
error: exit status 2
4. 1

Expected results:
4. Exit code should be 2

Additional info:

Comment 1 XiaochuanWang 2017-10-13 06:57:02 UTC
Checked on oc v3.7.0-0.150 and it reproduces.

Comment 2 Juan Vallejo 2017-10-17 21:31:57 UTC
Upstream PR: https://github.com/kubernetes/kubernetes/pull/54094

Comment 3 Juan Vallejo 2017-10-25 14:09:40 UTC
Upstream PR [1] has merged. Changes will be brought in to Origin after the next rebase.

1. https://github.com/kubernetes/kubernetes/pull/54094

Comment 4 Xingxing Xia 2018-07-23 08:22:23 UTC
Issue has been fixed for long time. Verified with oc v3.9.30:
[xxia@fedora28 my]$ oc plugin myplugin
ls: cannot access 'non-existed': No such file or directory
error: exit status 2
[xxia@fedora28 my]$ echo $?
2

Moving to VERIFIED directly, thanks

Comment 7 errata-xmlrpc 2019-03-13 22:27:23 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-2019:0403