Bug 1840411

Summary: [oc-cli]output a wrong context name for oc-project with --context
Product: OpenShift Container Platform Reporter: Hongkai Liu <hongkliu>
Component: ocAssignee: Jan Chaloupka <jchaloup>
Status: CLOSED ERRATA QA Contact: zhou ying <yinzhou>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.5CC: aos-bugs, jokerman, mfojtik
Target Milestone: ---   
Target Release: 4.6.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-10-27 16:01:41 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 Hongkai Liu 2020-05-26 21:42:24 UTC
oc version
Client Version: 4.5.0-202005220507-44354e2
Server Version: 4.3.18
Kubernetes Version: v1.16.2

oc config get-contexts
CURRENT   NAME      CLUSTER                                        AUTHINFO                                                  NAMESPACE
          api.ci    api-ci-openshift-org:443                       hongkailiu/api-ci-openshift-org:443                       hongkliu-test
*         app.ci    api-ci-l2s4-p1-openshiftapps-com:6443          hongkailiu/api-ci-l2s4-p1-openshiftapps-com:6443          hongkliu-test
          build01   api-build01-ci-devcluster-openshift-com:6443   hongkailiu/api-build01-ci-devcluster-openshift-com:6443   hongkliu-test
          build02   api-build02-gcp-ci-openshift-org:6443          hongkailiu/api-build02-gcp-ci-openshift-org:6443          hongkliu-test

oc project
Using project "hongkliu-test" from context named "app.ci" on server "https://api.ci.l2s4.p1.openshiftapps.com:6443".

oc --context build01 project
Using project "hongkliu-test" from context named "app.ci" on server "https://api.build01.ci.devcluster.openshift.com:6443".

It is expected to output the following for the last command:
Using project "hongkliu-test" from context named "build01" on server "https://api.build01.ci.devcluster.openshift.com:6443".

Comment 3 zhou ying 2020-06-10 09:27:57 UTC
Confirmed with latest oc , the issue not fixed:

[zhouying@dhcp-140-138 ~]$ oc version --client -o yaml 
clientVersion:
  buildDate: "2020-06-09T22:22:28Z"
  compiler: gc
  gitCommit: f30826ef04e45eea1745276dee8e693a08e29dba
  gitTreeState: clean
  gitVersion: 4.6.0-202006092217-f30826e
  goVersion: go1.13.4
  major: ""
  minor: ""
  platform: linux/amd64


[zhouying@dhcp-140-138 ~]$ oc config get-contexts
CURRENT   NAME                                                                          CLUSTER                                                    AUTHINFO      NAMESPACE
          /api-xxia0610-1-qe-devcluster-openshift-com:6443/testuser-2                   api-xxia0610-1-qe-devcluster-openshift-com:6443            testuser-2    
          /api-yinzhou4510-qe-devcluster-openshift-com:6443/testuser-30                 api-yinzhou4510-qe-devcluster-openshift-com:6443           testuser-30   
*         testz/api-xxia0610-1-qe-devcluster-openshift-com:6443/testuser-2              api-xxia0610-1-qe-devcluster-openshift-com:6443            testuser-2    testz
          zhouy/api-yinzhou4510-qe-devcluster-openshift-com:6443/testuser-30            api-yinzhou4510-qe-devcluster-openshift-com:6443           testuser-30   zhouy

[zhouying@dhcp-140-138 ~]$ oc --context zhouy/api-yinzhou4510-qe-devcluster-openshift-com:6443/testuser-30 project
error: you do not have rights to view project "testz" specified in your config or the project doesn't exist

Comment 4 zhou ying 2020-06-23 05:53:46 UTC
[zhouying@dhcp-140-138 ~]$ oc config get-contexts
CURRENT   NAME                                                                           CLUSTER                                               AUTHINFO     NAMESPACE
          /api-qe-groupd-0623-qe-devcluster-openshift-com:6443/testuser-3                api-qe-groupd-0623-qe-devcluster-openshift-com:6443   testuser-3   
          /api-yinzhoubug-qe-devcluster-openshift-com:6443/testuser-2                    api-yinzhoubug-qe-devcluster-openshift-com:6443       testuser-2   
*         user3-project/api-qe-groupd-0623-qe-devcluster-openshift-com:6443/testuser-3   api-qe-groupd-0623-qe-devcluster-openshift-com:6443   testuser-3   user3-project
          zhouy/api-yinzhoubug-qe-devcluster-openshift-com:6443/testuser-2               api-yinzhoubug-qe-devcluster-openshift-com:6443       testuser-2   zhouy

[zhouying@dhcp-140-138 ~]$ oc --context zhouy/api-yinzhoubug-qe-devcluster-openshift-com:6443/testuser-2 project
Using project "zhouy" on server "https://api.yinzhoubug.qe.devcluster.openshift.com:6443".

[zhouying@dhcp-140-138 ~]$ oc version --client -o yaml 
clientVersion:
  buildDate: "2020-06-22T17:36:51Z"
  compiler: gc
  gitCommit: b644a4b43e8d1cd9fa003e7686ce19454f456d08
  gitTreeState: clean
  gitVersion: 4.6.0-202006221729.p0-b644a4b
  goVersion: go1.13.4
  major: ""
  minor: ""
  platform: linux/amd64

Comment 6 errata-xmlrpc 2020-10-27 16:01:41 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 (OpenShift Container Platform 4.6 GA Images), 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-2020:4196