Bug 1281333

Summary: Error "No configuration file found" shows up when use kubeconfig option with non exist value
Product: OKD Reporter: Xingxing Xia <xxia>
Component: ocAssignee: Juan Vallejo <jvallejo>
Status: CLOSED CURRENTRELEASE QA Contact: Wei Sun <wsun>
Severity: low Docs Contact:
Priority: medium    
Version: 3.xCC: aos-bugs, jvallejo, mmccomas
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-12-09 21:50:17 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 Xingxing Xia 2015-11-12 10:30:22 UTC
Description of problem:
When use kubeconfig option (such as --context, --cluster) with non exist value, the command gives confusing error message: 
error: No configuration file found, please login or point to an existing file:


Version-Release number of selected component (if applicable):
oc v1.0.8-16-gd81eca7
kubernetes v1.1.0-origin-1107-g4c8e6f4

How reproducible:
Always

Steps to Reproduce:
1. Start openshift
2. oc login, create a project and new app
$ oc login --server=https://<server>:8443 -u gim -p abc
$ oc new-project gim-proj
$ oc new-app -f origin/examples/sample-app/application-template-stibuild.json
3. Check config file
$ oc config view
4. Use invalid values
1> $ oc get bc --user='gim/<server>:8443' --cluster='no-this-cluster' -n gim-proj
2> $ oc get bc --context='no-this-context'
5. 
1> check env
$ env | grep KUBE # Got empty
2> check config
$ ls ~/.kube/config
/home/tester/.kube/config


Actual results:
3.
apiVersion: v1
clusters:
- cluster:
    insecure-skip-tls-verify: true
    server: https://<server>:8443
  name: <server>:8443
contexts:
- context:
    cluster: <server>:8443
    namespace: gim-proj
    user: gim/<server>:8443
  name: gim-proj/<server>:8443/gim
current-context: gim-proj/<server>:8443/gim
kind: Config
preferences: {}
users:
- name: gim/<server>:8443
  user:
    token: 7vUToaM2QdO8DMCvCubPCabkiFoDjXFtrJdOYtde9As
4
1> and 2>:
error: No configuration file found, please login or point to an existing file:

  1. Via the command-line flag --config
  2. Via the KUBECONFIG environment variable
  3. In your home directory as ~/.kube/config

Expected results:
4. Should give prompt such as no context/cluster found (once upon a time, it prompted so!), rather than no configuration file found. Indeed the configuration file exists

Additional info:

Comment 1 Juan Vallejo 2016-07-19 22:01:16 UTC
Related PR: https://github.com/openshift/origin/pull/9944

Comment 2 Xingxing Xia 2016-10-19 10:26:01 UTC
Thanks. Verified in oc v1.4.0-alpha.0+e3a2814. Fixed. Now prompt message looks clearly:
$ oc get bc --user='no-this' --cluster='no-this-cluster' 
error: auth info "no-this" does not exist
$ oc get bc --cluster='no-this-cluster' 
error: cluster "no-this-cluster" does not exist