Bug 2102534

Summary: Can’t config oc tab completion on RHEL9
Product: OpenShift Container Platform Reporter: zhou ying <yinzhou>
Component: ocAssignee: Arda Guclu <aguclu>
oc sub component: oc QA Contact: zhou ying <yinzhou>
Status: CLOSED NOTABUG Docs Contact:
Severity: medium    
Priority: medium CC: maszulik, mfojtik
Version: 4.11Keywords: Reopened
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: 2022-08-16 11:04:44 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 2022-06-30 07:27:54 UTC
Description of problem:
Can’t config oc tab completion on RHEL9 


Version-Release number of selected component (if applicable):
oc version --client
Client Version: 4.11.0-0.nightly-2022-06-28-160049
Kustomize Version: v4.5.4


How reproducible:
always

Steps to Reproduce:
1.Enable the tab completion with follow command :
`oc completion bash > oc_bash_completion`
`sudo cp oc_bash_completion /etc/bash_completion.d/`
2. Check the oc completion 


Actual results:
Hit error when use tab :
oc get -bash: _get_comp_words_by_ref: command not found
-bash: _get_comp_words_by_ref: command not found

.bash_logout                                                      README.md
.bash_profile                                                     kubeconfig
.bashrc                                                           kubectl
.cshrc                                                            oc
.kube/                                                            oc_bash_completion
.ssh/                                                             openshift-client-linux-4.11.0-0.nightly-2022-06-28-160049.tar.gz
.tcshrc                                                           

Expected results:
2. No error and could enable tab completion for oc 


Additional info:

Comment 1 Maciej Szulik 2022-06-30 11:12:17 UTC
Looks like bash-completion package is not being installed on that RHEL9 machine of yours.

Comment 3 Maciej Szulik 2022-07-11 14:36:55 UTC
See my previous comment, from my quick googling you need bash-completion package. 

sudo dnf install bash-completion 

should most likely solve your problem.

Comment 5 Maciej Szulik 2022-07-12 14:48:05 UTC
Arda, on my local machine this works just fine, but I have completion installed permanently. I wonder if when source'ing (source oc_bash_completion) the completions mechanism responsible for returning the resources (for get command, for example) isn't working as it should be. It it likely that this is only rhel9 problem, because when I was talking with Zhou she mentioned it works just fine on rhel8, is it possible that something has change there or we're missing some wiring?

Comment 6 Arda Guclu 2022-07-13 06:57:07 UTC
As far as I understand, there is no general completion problem in RHEL9, it is a problem only for `oc get`. The patch for `oc get` completion bug was merged last week https://github.com/openshift/oc/pull/1186. 

Zhou, could you please try "oc get" completion in RHEl9 with the latest 4.12 version including that patch?