Bug 1840411 - [oc-cli]output a wrong context name for oc-project with --context
Summary: [oc-cli]output a wrong context name for oc-project with --context
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: oc
Version: 4.5
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: 4.6.0
Assignee: Jan Chaloupka
QA Contact: zhou ying
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-05-26 21:42 UTC by Hongkai Liu
Modified: 2020-10-27 16:01 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-10-27 16:01:41 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github openshift oc pull 444 0 None closed bug 1840411: oc project: respect --context flag 2020-06-23 03:11:20 UTC
Github openshift oc pull 469 0 None closed bug 1840411: oc project: rewrite context after kubeconfig is read 2020-06-23 03:11:20 UTC
Red Hat Product Errata RHBA-2020:4196 0 None None None 2020-10-27 16:01:43 UTC

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


Note You need to log in before you can comment on or make changes to this bug.