Bug 1835011

Summary: OC project shows misleading error when project exists in config but has been deleted from system
Product: OpenShift Container Platform Reporter: Sally <somalley>
Component: ocAssignee: Sally <somalley>
Status: CLOSED ERRATA QA Contact: zhou ying <yinzhou>
Severity: high Docs Contact:
Priority: high    
Version: 4.3.zCC: aos-bugs, jchaloup, jokerman, maszulik, mfojtik, nmanos, oblaut, tfreger, yinzhou
Target Milestone: ---   
Target Release: 4.5.0   
Hardware: Unspecified   
OS: Linux   
Fixed In Version: Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: 1826676 Environment:
Last Closed: 2020-07-13 17:38:07 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Sally 2020-05-12 22:13:03 UTC
+++ This bug was initially created as a clone of Bug #1826676 +++

When a user runs `oc project` but the kubeconfig current context is a project that has been deleted (only way this will happen is if user has no other projects) the user gets a misleading error.  The error message should be improved. 

How reproducible:

Steps to Reproduce:
1) Login to an existing cluster
$ oc new-project test
$ oc delete project test
$ oc project

user gets misleading error: 'error: you do not have rights to view project "test".' 
If user has no projects, should instead see 
'error: You are not a member of any projects. You can request a project to be created with the 'new-project' command.'

Comment 1 Maciej Szulik 2020-05-13 14:25:14 UTC
The problem appears when you're using a regular non-system:admin user:

oc project
error: you do not have rights to view project "tesla"

with system:admin the message is ok:

oc status
error: the project "tesla" specified in your config does not exist

Comment 2 Sally 2020-05-20 16:28:36 UTC
This bug is actively being worked on.

Comment 5 zhou ying 2020-05-27 03:03:23 UTC
$ ./oc version -o yaml 
  buildDate: "2020-05-26T21:24:07Z"
  compiler: gc
  gitCommit: 384535d084fda4ab8b3e37c995bf20ed46dbce51
  gitTreeState: dirty
  gitVersion: 384535d0
  goVersion: go1.13.4
  major: ""
  minor: ""
  platform: windows/amd64

$ ./oc project
error: you do not have rights to view project "zhouy" specified in your config or the project doesn't exist

Comment 6 errata-xmlrpc 2020-07-13 17:38:07 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.