Bug 1963053

Summary: `oc whoami --show-console` should show the web console URL, not the server api URL
Product: OpenShift Container Platform Reporter: Jian Zhang <jiazha>
Component: ocAssignee: Maciej Szulik <maszulik>
oc sub component: oc QA Contact: zhou ying <yinzhou>
Status: CLOSED ERRATA Docs Contact:
Severity: high    
Priority: medium CC: aos-bugs, maszulik, mfojtik
Version: 4.8Keywords: Reopened
Target Milestone: ---   
Target Release: 4.10.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-03-11 18:15:11 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 Jian Zhang 2021-05-21 09:37:08 UTC
Description of problem:
The output of the `oc whoami --show-console` is the server API URL, not the console.
[cloud-user@preserve-olm-env jian]$ ./oc whoami --show-console
https://api.zzhao-0521.qe.gcp.devcluster.openshift.com:6443

[cloud-user@preserve-olm-env jian]$ ./oc whoami --show-server
https://api.zzhao-0521.qe.gcp.devcluster.openshift.com:6443


Version-Release number of selected component (if applicable):
[cloud-user@preserve-olm-env jian]$ ./oc version
Client Version: 4.8.0-0.nightly-2021-05-19-123944
Server Version: 4.8.0-0.nightly-2021-05-19-123944
Kubernetes Version: v1.21.0-rc.0+2df5a14


How reproducible:
always

Steps to Reproduce:
1. Install OCP4.8.
2. Get the console URL by using the `oc whoami --show-console`.



Actual results:
It print the current server's REST API URL, not the the current server's web console URL. The output is the same as the `oc whoami --show-server`.
[cloud-user@preserve-olm-env jian]$ ./oc whoami --show-console
https://api.zzhao-0521.qe.gcp.devcluster.openshift.com:6443

mac:~ jianzhang$ nslookup https://api.zzhao-0521.qe.gcp.devcluster.openshift.com:6443
Server:		10.72.17.5
Address:	10.72.17.5#53

** server can't find https://api.zzhao-0521.qe.gcp.devcluster.openshift.com:6443: NXDOMAIN
https://user-images.githubusercontent.com/15416633/119116485-dfd47d80-ba5a-11eb-8c10-2dd9f493fa27.png

[cloud-user@preserve-olm-env jian]$ ./oc whoami --show-server
https://api.zzhao-0521.qe.gcp.devcluster.openshift.com:6443


Expected results:
It should print the server's web console URL.
mac:~ jianzhang$ oc get route -n openshift-console
NAME        HOST/PORT                                                                     PATH   SERVICES    PORT    TERMINATION          WILDCARD
console     console-openshift-console.apps.zzhao-0521.qe.gcp.devcluster.openshift.com            console     https   reencrypt/Redirect   None
downloads   downloads-openshift-console.apps.zzhao-0521.qe.gcp.devcluster.openshift.com          downloads   http    edge/Redirect        None

mac:~ jianzhang$ nslookup  console-openshift-console.apps.zzhao-0521.qe.gcp.devcluster.openshift.com
Server:		10.68.5.26
Address:	10.68.5.26#53

Non-authoritative answer:
Name:	console-openshift-console.apps.zzhao-0521.qe.gcp.devcluster.openshift.com
Address: 34.134.131.4

Additional info:

Comment 3 Maciej Szulik 2021-05-24 09:09:25 UTC
This is working as designed, see the output from oc:

$ ./oc --loglevel=8 whoami --show-console
I0521 06:14:12.881532  102149 loader.go:372] Config loaded from file:  /kubeconfig
I0521 06:14:12.882970  102149 round_trippers.go:432] GET https://api.example.com:6443/api/v1/namespaces/openshift-config-managed/configmaps/console-public
I0521 06:14:12.882998  102149 round_trippers.go:438] Request Headers:
I0521 06:14:12.883003  102149 round_trippers.go:442]     User-Agent: oc/4.8.0 (linux/amd64) kubernetes/629bdbe
I0521 06:14:12.883008  102149 round_trippers.go:442]     Accept: application/json, */*
I0521 06:14:13.040692  102149 round_trippers.go:457] Response Status: 404 Not Found in 157 milliseconds

we're trying to read console address, but since the configmap which should contain that address was removed, oc can't and falls back to printing API endpoint.

Comment 4 Jian Zhang 2021-11-24 03:26:51 UTC
Hi Maciej,

Sorry for the late reply, I missed it. 

> we're trying to read console address, but since the configmap which should contain that address was removed, oc can't and falls back to printing API endpoint

Which configmap? Could you help explain more? Thanks!


I tried it whit the latest `oc`, it works well. I changed the status to VERIFIED, please let me know if any concerns, thanks!

[cloud-user@preserve-olm-env jian]$ oc version
Client Version: 4.10.0-0.nightly-2021-11-04-001635
Server Version: 4.10.0-0.nightly-2021-11-23-133134
Kubernetes Version: v1.22.1+8e73d6b
[cloud-user@preserve-olm-env jian]$ oc --loglevel=8 whoami --show-console
I1123 22:10:44.023142  367364 loader.go:372] Config loaded from file:  /data/jian/24-kubeconfig
I1123 22:10:44.024343  367364 round_trippers.go:432] GET https://api.qe-daily-1124.qe.devcluster.openshift.com:6443/api/v1/namespaces/openshift-config-managed/configmaps/console-public
I1123 22:10:44.024381  367364 round_trippers.go:438] Request Headers:
I1123 22:10:44.024389  367364 round_trippers.go:442]     Accept: application/json, */*
I1123 22:10:44.024402  367364 round_trippers.go:442]     User-Agent: oc/4.10.0 (linux/amd64) kubernetes/b241000
I1123 22:10:44.314502  367364 round_trippers.go:457] Response Status: 200 OK in 290 milliseconds
I1123 22:10:44.314528  367364 round_trippers.go:460] Response Headers:
I1123 22:10:44.314533  367364 round_trippers.go:463]     X-Kubernetes-Pf-Prioritylevel-Uid: 7d7f1323-a1ba-4db4-8e0d-96e15f381d63
I1123 22:10:44.314537  367364 round_trippers.go:463]     Content-Length: 516
I1123 22:10:44.314550  367364 round_trippers.go:463]     Date: Wed, 24 Nov 2021 03:13:19 GMT
I1123 22:10:44.314557  367364 round_trippers.go:463]     Audit-Id: b96e23e7-b5f3-47c0-b762-0e255d109149
I1123 22:10:44.314570  367364 round_trippers.go:463]     Cache-Control: no-cache, private
I1123 22:10:44.314574  367364 round_trippers.go:463]     Content-Type: application/json
I1123 22:10:44.314581  367364 round_trippers.go:463]     X-Kubernetes-Pf-Flowschema-Uid: 5b56a28f-b067-45e6-a71a-3fa102e17fb3
I1123 22:10:44.314636  367364 request.go:1181] Response Body: {"kind":"ConfigMap","apiVersion":"v1","metadata":{"name":"console-public","namespace":"openshift-config-managed","uid":"ad3cba11-865a-402a-a8cd-295dc85bf5b5","resourceVersion":"24000","creationTimestamp":"2021-11-23T23:24:55Z","managedFields":[{"manager":"console","operation":"Update","apiVersion":"v1","time":"2021-11-23T23:24:55Z","fieldsType":"FieldsV1","fieldsV1":{"f:data":{".":{},"f:consoleURL":{}}}}]},"data":{"consoleURL":"https://console-openshift-console.apps.qe-daily-1124.qe.devcluster.openshift.com"}}
https://console-openshift-console.apps.qe-daily-1124.qe.devcluster.openshift.com

Comment 6 Jian Zhang 2022-01-05 08:41:07 UTC
Hi Maciej,

Got it, thanks for your explanation!