Bug 1766099

Summary: Options to use api-resources with oc command
Product: OpenShift Container Platform Reporter: Abhishek <aabhishe>
Component: ocAssignee: Maciej Szulik <maszulik>
Status: CLOSED ERRATA QA Contact: zhou ying <yinzhou>
Severity: low Docs Contact:
Priority: low    
Version: 3.11.0CC: ansverma, aos-bugs, dkulkarn, jokerman, maszulik, mfojtik, yinzhou
Target Milestone: ---   
Target Release: 4.1.z   
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: 2019-12-02 17:47:49 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 Abhishek 2019-10-28 09:11:47 UTC
Description of problem: Bash auto compltion is broken when we run verb + noun like oc get <TAB><TAB>, oc edit <TAB><TAB> etc..

Current Result
Bash auto-completion does not work 

Expected Result
List the api-resources

Comment 2 Maciej Szulik 2019-10-28 20:10:16 UTC
This was fixed in 4.1, I don't see too much chance in backporting this fix into older release until explicitly asked and approved by BU/PM.

Comment 4 zhou ying 2019-10-29 05:48:36 UTC
Confirmed with latest oc version, the issue has fixed:
[root@dhcp-140-138 ~]# oc version 
Client Version: version.Info{Major:"4", Minor:"1+", GitVersion:"v4.1.22", GitCommit:"24e868508", GitTreeState:"clean", BuildDate:"2019-10-26T03:37:23Z", GoVersion:"go1.11.13", Compiler:"gc", Platform:"linux/amd64"}


[root@dhcp-140-138 ~]# oc edit 
Display all 155 possibilities? (y or n)
alertmanagers.monitoring.coreos.com                           endpoints                                                     operatorgroups.operators.coreos.com
apiservers.config.openshift.io                                events                                                        operatorhubs.config.openshift.io
......

Comment 6 errata-xmlrpc 2019-11-07 06:32:58 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:3294

Comment 8 zhou ying 2019-11-13 09:59:35 UTC
Confirmed with oc , 4.1 could compatible with ocp server 3.11:
[root@dhcp-140-138 ~]# oc version
Client Version: version.Info{Major:"4", Minor:"1+", GitVersion:"v4.1.24", GitCommit:"c41acf267", GitTreeState:"clean", BuildDate:"2019-11-08T08:19:24Z", GoVersion:"go1.11.13", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"11+", GitVersion:"v1.11.0+d4cacc0", GitCommit:"d4cacc0", GitTreeState:"clean", BuildDate:"2019-10-31T21:06:55Z", GoVersion:"go1.10.8", Compiler:"gc", Platform:"linux/amd64"}



[root@dhcp-140-138 ~]# oc edit 
alertmanagers.monitoring.coreos.com                           events.events.k8s.io                                          prometheusrules.monitoring.coreos.com
apiservices.apiregistration.k8s.io                            groups.user.openshift.io                                      rangeallocations.security.openshift.io
appliedclusterresourcequotas.quota.openshift.io               horizontalpodautoscalers.autoscaling                          replicasets.apps
....

Comment 9 Devendra Kulkarni 2019-11-14 05:21:44 UTC
$ wget https://mirror.openshift.com/pub/openshift-v4/clients/oc/4.1.24-201911080309.git.0.c41acf2.el7/linux/oc.tar.gz
--2019-11-13 23:53:19--  https://mirror.openshift.com/pub/openshift-v4/clients/oc/4.1.24-201911080309.git.0.c41acf2.el7/linux/oc.tar.gz
Resolving mirror.openshift.com (mirror.openshift.com)... 54.172.173.155, 54.172.163.83, 54.173.18.88
Connecting to mirror.openshift.com (mirror.openshift.com)|54.172.173.155|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 22456367 (21M) [application/x-gzip]
Saving to: ‘oc.tar.gz’

100%[========================================================================================================>] 22,456,367  10.6MB/s   in 2.0s   

2019-11-13 23:53:21 (10.6 MB/s) - ‘oc.tar.gz’ saved [22456367/22456367]


$ tar -xvf oc.tar.gz

$ ls
  oc 	oc.tar.gz    index.html    netapp-api-exporter



$ /home/quicklab/oc version
Client Version: version.Info{Major:"4", Minor:"1+", GitVersion:"v4.1.24", GitCommit:"c41acf267", GitTreeState:"clean", BuildDate:"2019-11-08T08:19:24Z", GoVersion:"go1.11.13", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"11+", GitVersion:"v1.11.0+d4cacc0", GitCommit:"d4cacc0", GitTreeState:"clean", BuildDate:"2019-10-10T16:48:37Z", GoVersion:"go1.10.8", Compiler:"gc", Platform:"linux/amd64"}


$ /home/quicklab/oc get 
.ansible/               .bash_profile           index.html              netapp-api-exporter/    .pki/                   .viminfo
.bash_history           .bashrc                 .kube/                  oc                      pv.txt                  
.bash_logout            hawkular-metrics-1.yml  .lesshst                oc.tar.gz               .ssh/

$ /home/quicklab/oc edit 
.ansible/               .bash_profile           index.html              netapp-api-exporter/    .pki/                   .viminfo
.bash_history           .bashrc                 .kube/                  oc                      pv.txt                  
.bash_logout            hawkular-metrics-1.yml  .lesshst                oc.tar.gz               .ssh/ 



oc-client binary of ocp4.1.24 does not work in OCP3.11.
Also tried oc-client binary of ocp4.1.23 but still does not work.

Comment 13 zhou ying 2019-12-12 01:49:44 UTC
Please refer https://bugzilla.redhat.com/show_bug.cgi?id=1766099#c12

Comment 15 zhou ying 2020-01-02 06:56:11 UTC
From the first <tab> action it looks like the autocompletion is working correctly, for further invocation a running cluster is needed,
do you have one?


That mean you need to login the cluster.