Bug 1419857

Summary: oc login ignores --cluster and --context options
Product: OKD Reporter: Aleksandar Kostadinov <akostadi>
Component: ocAssignee: Juan Vallejo <jvallejo>
Status: CLOSED WONTFIX QA Contact: Xingxing Xia <xxia>
Severity: low Docs Contact:
Priority: medium    
Version: 3.xCC: aos-bugs, jliggitt, mmccomas, pweil
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-10-25 19:11:13 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 Aleksandar Kostadinov 2017-02-07 09:07:29 UTC
Description of problem:
When performing `oc login` the options --cluster and --context are ignored. One has to first do `oc config use-context` and then `oc login`. Once logged it, the cluster and context options work for other commands.

I think this is inconsistent and inconvenient.

As a user I'd expect to be able to perform `oc login` with one of those commands. Then default context should be changed to the one used for login. Or even if default context is not switched, then that would be better than having to switch contexts just to be able to login.

Version-Release number of selected component (if applicable):
3.4.1.2

How reproducible:
always

Steps to Reproduce:
1. setup ~/.kube/config with 2 clusters
2. oc login --context=not-current-context


Actual results:
login is performed against current context instead of the specified context on command line

Expected results:
login is performed against the server/context specified on command line

Comment 1 Juan Vallejo 2017-02-07 23:49:48 UTC
Related PR: https://github.com/openshift/origin/pull/12859

Comment 2 Juan Vallejo 2017-10-25 19:11:13 UTC
Per Jordan's comment here [1], commands such as `oc project` are meant to be used to address the case of a user wanting to switch to a different context / cluster.

It is not the intent of `oc login` to allow the user to manually manage contexts.

1. https://github.com/openshift/origin/pull/12859#issuecomment-278851380

Comment 3 Aleksandar Kostadinov 2017-10-25 20:57:03 UTC
Any reason to not make it easier for the user to actually use different clusters/contexts?

As a user of multiple environments I can tell you that it is a great PITA to do so. I need to remember cluster hostname, project and username I'm using on each cluster. With the ability to have shorter mnemonic contexts, it is much more manageable.

That's why I filed the original bugzilla - because I find it hardly usable.

I don't care whether the tool was originally meant to allow certain usage. I'm proposing to make it more useful for multi-cluster use cases based on my experience using that tool. It is disappointing to see the request closed without a logical reason why it is a bad idea. Moreover there is a related pull request already.

Comment 4 Red Hat Bugzilla 2023-09-14 03:53:19 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 1000 days