Bug 1670652

Summary: [MSTR-8] The new mechanism for oc plugin of git-style does not work
Product: OpenShift Container Platform Reporter: zhou ying <yinzhou>
Component: ocAssignee: Maciej Szulik <maszulik>
Status: CLOSED ERRATA QA Contact: zhou ying <yinzhou>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.1.0CC: aos-bugs, jokerman, maszulik, mmccomas, xxia
Target Milestone: ---   
Target Release: 4.1.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: Plugins were recognized only when having kubect- prefix Consequence: Not all plugins were working. Fix: Allow both kubectl- and oc- prefix for plugins. Result: Both plugins are working as expected.
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-06-04 10:42:28 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 zhou ying 2019-01-30 03:11:07 UTC
Description of problem:
The new mechanism for oc plugin of git-style does not work

Version-Release number of selected component (if applicable):
oc v4.0.0-0.149.0
kubernetes v1.12.4+50c2f2340a


How reproducible:
Always

Steps to Reproduce:
1. Install the latest OC  and kubectl client;
2. Create the plugin :
   `echo -e '#!/bin/bash\n echo "Plugin oc-foo_bar is executed"' > ./oc-foo_bar`
   `chmod +x oc-foo_bar`
   `mv oc-foo_bar /usr/local/bin/`
3. Use `oc plugin list` command to list the plugin
4. Change the plugin name to 'kubectl-foo_bar' , use the 'oc plugin list' command
5. Use `oc plugin -h` command to check the help info.

Actual results:
3. Could not find the oc plugin:
[root@dhcp-140-138 ~]# oc plugin list
error: unable to find any kubectl plugins in your PATH

4. Show the kubectl-compatible plugins are available, but could not use the plugin
5. The help info was not clear



Expected results:
3. Should find the oc plugin;
4. Only the kubectl could use the plugin , the oc client could not use the kubectl-compatible plugin.
5. Should give clear documentation and examples for how to write the plugin.


Additional info:

Comment 1 Juan Vallejo 2019-01-30 19:27:21 UTC
Thanks for catching this.
Origin PR: https://github.com/openshift/origin/pull/21909

Will open upstream PR once we decide if we want to carry a patch for any of the upstream changes.

Comment 2 Juan Vallejo 2019-02-04 15:34:15 UTC
Upstream [1] and Origin [2] PRs have merged.

1. https://github.com/kubernetes/kubernetes/pull/73642
2. https://github.com/openshift/origin/pull/21909

Comment 6 zhou ying 2019-02-14 02:53:02 UTC
The new mechanism works fine now:
[root@dhcp-140-138 ~]# oc plugin list
The following compatible plugins are available:

/root/bin/oc-foo
/usr/bin/oc-fao_bar
/usr/local/sbin/oc-foo_bar
/usr/local/sbin/oc-foo_bar_baz
[root@dhcp-140-138 ~]# oc foo
I am a plugin named foo
[root@dhcp-140-138 ~]# oc foo-bar
Plugin oc-foo-bar is executed
[root@dhcp-140-138 ~]# oc version
oc v4.0.0-0.170.0
kubernetes v1.12.4+45dbe929fa
features: Basic-Auth GSSAPI Kerberos SPNEGO

Comment 9 errata-xmlrpc 2019-06-04 10:42:28 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:0758