Bug 1305765 - windows oc cli doesn't use home env variable as home directory
Summary: windows oc cli doesn't use home env variable as home directory
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: oc
Version: 3.1.0
Hardware: All
OS: Windows
unspecified
medium
Target Milestone: ---
: ---
Assignee: Fabiano Franz
QA Contact: Wei Sun
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-02-09 08:00 UTC by Christophe Augello
Modified: 2019-10-10 11:08 UTC (History)
8 users (show)

Fixed In Version: atomic-openshift-3.1.1.905-1.git.0.ef5902f.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-05-12 16:28:30 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2016:1064 0 normal SHIPPED_LIVE Important: Red Hat OpenShift Enterprise 3.2 security, bug fix, and enhancement update 2016-05-12 20:19:17 UTC

Description Christophe Augello 2016-02-09 08:00:32 UTC
Description of problem:
Since oc 3.1.1.6 windows oc cli seems to use homeDrive + homePath to define the user's home directory. before 3.1.1.6 oc kubeconfig was written in directory from HOME env variable.

Version-Release number of selected component (if applicable):
oc cli 3.1.1.6

How reproducible:


Steps to Reproduce:
1. Have homeDrive != actual home drive (Z:\ vs C:\

Actual results:
C:\Users\XXXX>oc version
oc v3.1.1.6
kubernetes v1.1.0-origin-1107-g4c8e6f4

C:\Users\XXXX>oc whoami
error: open Z:\/.kube/config: The system cannot find the path specified.

C:\Users\XXXX>env | grep HOMEDRIVE
HOMEDRIVE=Z:

C:\Users\SHJN2064>env | grep HOME
HOME=/c/Users/XXXX

Expected results:
If HOME is set, use home prior to homeDrive + homePath

Additional info:

Comment 1 Fabiano Franz 2016-02-11 20:58:16 UTC
We have to be careful about relying in the HOME env var on Windows because in many cases it is set to the wrong location, we've seen for example HOME=/c in a few cases. 

The recommended way of doing it is to first try HOMEDRIVE + HOMEPATH and then fallback to USERPROFILE, which is what we are doing[1]. We could add a check for the existence of these two locations, and add HOME as a third location which would be used if any of the other two options are available as env vars and/or path doesn't actually exist.

Could you please confirm what you have in USERPROFILE? 

[1] References
https://support.microsoft.com/en-us/kb/100843
http://blogs.msdn.com/b/patricka/archive/2010/03/18/where-should-i-store-my-data-and-configuration-files-if-i-target-multiple-os-versions.aspx

Comment 2 Fabiano Franz 2016-02-19 17:24:34 UTC
Fixed in https://github.com/openshift/origin/pull/7449

Comment 3 Yanping Zhang 2016-02-22 05:00:35 UTC
The fix works on latest origin client oc v1.1.3-170-g14b50fd, but the codes are not merged in enterprise, so still can reproduce the bug on the latest oc v3.1.1.904, wait for a puddle containing the fix to verify the bug.

Comment 4 Christophe Augello 2016-02-22 12:15:39 UTC
@Fabian

USERPROFILE=C:\Users\XXXX

Could we implement in https://github.com/openshift/origin/pull/7449 in downstream?

Comment 5 Fabiano Franz 2016-02-22 17:37:30 UTC
Christophe yes, it's coming downstream soon.

Comment 6 Yanping Zhang 2016-02-23 02:35:37 UTC
Tested on v3.1.1.905
Steps to verify:
1.1
$ export HOMEDRIVE=Z:
1.2.
$ env|grep HOME
HOMEPATH=\Users\oppenshift
HOME=/c/Users/oppenshift
HOMEDRIVE=Z:
1.3.
$ ./oc.exe whoami
yanpzhan
2.1
$ env|grep HOME
HOMEPATH=\Users\oppenshift
HOME=/z/Users/oppenshift
HOMEDRIVE=C:
2.2 
$ ./oc.exe whoami
yanpzhan

The bug has been fixed on v3.1.1.905, so move it to Verified.

Comment 9 errata-xmlrpc 2016-05-12 16:28:30 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.

https://access.redhat.com/errata/RHSA-2016:1064


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