Bug 1471160 - use current context when logging in
Summary: use current context when logging in
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: oc
Version: 3.6.1
Hardware: Unspecified
OS: Unspecified
medium
low
Target Milestone: ---
: ---
Assignee: Juan Vallejo
QA Contact: Xingxing Xia
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-07-14 14:31 UTC by Aleksandar Kostadinov
Modified: 2017-10-25 18:09 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-10-25 18:09:08 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Aleksandar Kostadinov 2017-07-14 14:31:06 UTC
Description of problem:
`oc` tool supports operation against multiple clusters. User can edit ~/.kube/config file to rename contexts to make them easier to remember.

The issue is that when current context is for example `myeasyname` and the next day user performs `oc login` a new context is created with the default name `project/clustername/username`. So the user cannot anymore use `myeasyname` context unless user edits kubeconfig again. 

Version-Release number of selected component (if applicable):
oc v3.6.124

How reproducible:
always

Steps to Reproduce:
1. oc login
2. rename context
3. wait credentials to expire
4. oc login

Actual results:
a new context is created and current context is the newly created context

Expected results:
the existing context is reused

Additional info:
I filed an issue about shell completion for --context option [1]. I think it is also very important for user experience working with multiple environments.

[1] https://github.com/openshift/origin/issues/15184

Comment 1 Juan Vallejo 2017-09-05 22:34:27 UTC
I think a solution to this would be to have the `oc login` command acknowledge the global `--context` flag (if one is provided).

That way, if it is a user's intent to actually have the default context with a default name be created on login, the command's current behavior remains unchanged.

Origin PR: https://github.com/openshift/origin/pull/16161

Comment 2 Aleksandar Kostadinov 2017-09-06 11:04:44 UTC
Provided that `oc` uses current context server for the login command, then it makes sense to update current context. I think it only makes sense to create a new context when user changes `server` or `user` when logging in.

Comment 3 Juan Vallejo 2017-10-25 18:09:08 UTC
Although the idea behind this bug makes sense, it looks like we are not planning on allowing users to manage contexts via `oc login` [1].

1. https://github.com/openshift/origin/pull/16161#issuecomment-328577474

Closing this bug for now.


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