Bug 1649883

Summary: oc completion doesn't auto complete resource type names
Product: OpenShift Container Platform Reporter: Jindřich Káňa <jindrich.kana>
Component: ocAssignee: Maciej Szulik <maszulik>
Status: CLOSED ERRATA QA Contact: zhou ying <yinzhou>
Severity: low Docs Contact:
Priority: medium    
Version: 3.11.0CC: aos-bugs, dapark, jindrich.kana, jokerman, maszulik, mmccomas
Target Milestone: ---   
Target Release: 4.1.0   
Hardware: other   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-06-04 10:40:51 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 Jindřich Káňa 2018-11-14 17:12:41 UTC
Description of problem:


Version-Release number of selected component (if applicable):
[root@ocpbox ~]# oc version
oc v3.11.16
kubernetes v1.11.0+d4cacc0
features: Basic-Auth GSSAPI Kerberos SPNEGO

Server https://loadbalancer1.8670.internal:443
openshift v3.11.16
kubernetes v1.11.0+d4cacc0


How reproducible:


Steps to Reproduce:
1. source <(oc completion bash)
2. then try to type oc {get,describe} {any object} and competion will not work
3. then you can try again different way how to resolve the issue
4. oc completion bash > bash_completion.sh
5. source bash_completion.sh

and the completion will still not work.


Actual results:

no completion in subcommands - like oc {get, describe} {anyObject}

Expected results:

completion of e.g. oc get {possible sub sub commands services, deploymentconfig, pods, etc}
Additional info:

Comment 1 Juan Vallejo 2018-11-14 18:58:02 UTC
What version of Bash are you using?
Also could you ensure that you have the "bash-completion" package installed? ("sudo dnf install bash-completion" in Fedora)

Additionally, if you do have bash-completion already installed, could you try placing the output of `oc completion bash` under "/etc/bash_completion.d/oc_completion"? (oc completion bash > /etc/bash_completion.d/oc_completion")

Comment 2 Jindřich Káňa 2018-11-15 05:41:35 UTC
(In reply to Juan Vallejo from comment #1)
> What version of Bash are you using?
[root@bastion ~]# bash -version
GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)

> Also could you ensure that you have the "bash-completion" package installed?
[root@bastion ~]# rpm -qa|grep bash-completion
bash-completion-2.1-6.el7.noarch

> ("sudo dnf install bash-completion" in Fedora)
> 
> Additionally, if you do have bash-completion already installed, could you
> try placing the output of `oc completion bash` under
> "/etc/bash_completion.d/oc_completion"? (oc completion bash >
> /etc/bash_completion.d/oc_completion")
This was already done as well. I have tried to fix that in many ways.

Have you tried that? My colleague who tested this for me as well on different environment confirmed, that the completion of oc sub sub commands are working on 3.9 but not on 3.11.

Comment 3 Xingxing Xia 2018-11-15 10:20:28 UTC
I can reproduce with oc 3.11 (latest 3.11.44) given bash-completion is already installed.
$ oc completion bash > bash_completion.sh
$ source bash_completion.sh # same result if `yum install atomic-openshift-clients -y` and `source /etc/bash_completion.d/oc`

$ oc ge<tab> # can auto complete `get`
$ oc create sec<tab> # can auto sub command `secret`
But:
$ oc get proj<tab> # cannot auto complete project
$ oc get deploy<tab> # cannot auto complete deploymentconfig
$ oc get rout<tab> # cannot auto complete route
... all resource type names cannot be auto-completed

oc 3.9 (latest 3.9.51) does NOT have above issues (but it DOES reproduce bug 1534371, and it can NOT auto complete svc/service NOW whereas 1534371#c0 can)

Comment 4 Jindřich Káňa 2018-11-15 12:59:55 UTC
I cannot complete any object after subcommand (the verb) - e.g. oc <tab> will list me everything what is possible, but after subcommands oc {get,describe,edit,export} <tab> will not list nor autocomplete anything.
 
[root@bastion ~]# oc version
oc v3.11.16
kubernetes v1.11.0+d4cacc0
features: Basic-Auth GSSAPI Kerberos SPNEGO

Server https://loadbalancer1.8670.internal:443
openshift v3.11.16
kubernetes v1.11.0+d4cacc0

[root@bastion ~]# bash -version
GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

[root@bastion ~]# uname -a
Linux bastion.8670.example.opentlc.com 3.10.0-862.el7.x86_64 #1 SMP Wed Mar 21 18:14:51 EDT 2018 x86_64 x86_64 x86_64 GNU/Linux

[root@bastion ~]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.5 (Maipo)

Comment 5 Juan Vallejo 2018-12-04 21:52:22 UTC
I am not able to reproduce this with a 4.0 client.
Tested with both bash and zsh:

```
$ oc version
oc v4.0.0-alpha.0+5974351-741-dirty
kubernetes v1.11.0+59743510d0
features: Basic-Auth GSSAPI Kerberos SPNEGO

$ source <(oc completion bash)
$ oc ge<tab>               # auto-completes to "get"
$ oc create sec<tab>       # auto completes "secret"
$ oc get replicationc<tab> # auto-completes "replicationcontrollers"
$ oc get pods <tab>        # suggests all pods in current namespace

# openshift-specific resources
$ oc get proj<tab>         # auto-completes to "projects.project.openshift.io"
$ oc get projects.project.openshift.io <tab> # suggests all available projects
$ oc get deployment<tab>   # suggests: 
deploymentconfigs.apps.openshift.io, deployments.apps deployments.extensions

$ oc get deploymentconfigs.apps.openshift.io # suggests all dc's in current project
```

This is not a release blocker.

Comment 6 zhou ying 2018-12-05 07:37:23 UTC
Confirmed with latest version, the issue has fixed:
[root@dhcp-140-138 ~]# oc version 
oc v4.0.0-0.82.0
kubernetes v1.11.0+6855010f70

Comment 11 errata-xmlrpc 2019-06-04 10:40:51 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