Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1406066

Summary: [RFE] Throw a more user friendly error if oc hits an open port that doesn't belong to OpenShift
Product: OpenShift Container Platform Reporter: Nick Schuetz <nschuetz>
Component: ocAssignee: Maciej Szulik <maszulik>
Status: CLOSED CURRENTRELEASE QA Contact: Xingxing Xia <xxia>
Severity: low Docs Contact:
Priority: medium    
Version: 3.3.1CC: aos-bugs, ffranz, jokerman, mmccomas, nschuetz, xiaocwan, yanpzhan, yapei
Target Milestone: ---   
Target Release: 3.7.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Feature: Provide more user friendly error when trying to log to non-OpenShift cluster. Reason: Be able to clearly identify why login fails. Result: oc login provides more user friendly error when trying to login into non-OpenShift cluster.
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-11-21 18:38:10 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 Nick Schuetz 2016-12-19 15:59:09 UTC
Description of problem:

oc throws raw HTTP response when it's unable to login on an open port. I suggest making it more human friendly by enhancing the error message.

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

3.3.1.7

How reproducible:

Always

Steps to Reproduce:

1. oc login <your server with port 443 open but not by OpenShift>

Actual results:


$ oc login ocp.example.com --loglevel=8
I1219 09:25:42.487338   39620 loader.go:330] Config loaded from file /Users/jmamma/.kube/config
I1219 09:25:42.488934   39620 round_trippers.go:296] HEAD https://ocp.example.com:443/
I1219 09:25:42.488968   39620 round_trippers.go:303] Request Headers:
I1219 09:25:42.547686   39620 round_trippers.go:321] Response Status:  in 58 milliseconds
I1219 09:25:42.547710   39620 round_trippers.go:324] Response Headers:
The server is using a certificate that does not match its hostname: x509: certificate is valid for www.example.com, not ocp.example.com
You can bypass the certificate check, but any data you send to the server could be intercepted by others.
Use insecure connections? (y/n): y

I1219 09:25:44.960986   39620 round_trippers.go:296] GET https://ocp.example.com:443/oauth/authorize?response_type=token&client_id=openshift-challenging-client
I1219 09:25:44.960994   39620 round_trippers.go:303] Request Headers:
I1219 09:25:44.960998   39620 round_trippers.go:306]     X-Csrf-Token: 1
I1219 09:25:44.993021   39620 round_trippers.go:321] Response Status: 503 Service Unavailable in 32 milliseconds
I1219 09:25:44.993040   39620 round_trippers.go:324] Response Headers:
I1219 09:25:44.993044   39620 round_trippers.go:327]     Content-Type: text/html
I1219 09:25:44.993048   39620 round_trippers.go:327]     Pragma: no-cache
I1219 09:25:44.993050   39620 round_trippers.go:327]     Cache-Control: private, max-age=0, no-cache, no-store
I1219 09:25:44.993053   39620 round_trippers.go:327]     Connection: close
I1219 09:25:44.993202   39620 helpers.go:187] server response object: [{
  "metadata": {},
  "status": "Failure",
  "message": "Internal error occurred: unexpected response: 503",
  "reason": "InternalError",
  "details": {
    "causes": [
      {
        "message": "unexpected response: 503"
      }
    ]
  },
  "code": 500
}]
F1219 09:25:44.993218   39620 helpers.go:110] Error from server: Internal error occurred: unexpected response: 503

Expected results:

Message indicating that the server is not available on that port. Maybe still include the HTTP response, but perhaps there should be some suggestion to use <your server url>:8443 too?

Additional info:

Right now if you hit a port that isn't open you get:

"You may want to try using the default cluster port: https://ocp.example.com:8443"

Comment 1 Juan Vallejo 2017-01-24 19:45:04 UTC
> Message indicating that the server is not available on that port. Maybe still 
> include the HTTP response, but perhaps there should be some suggestion to use 
> <your server url>:8443 too?

I agree with including a suggestion to try the default cluster port, however it would not always be accurate to say that "the server is not available on that port", as it might be the openshift server that is being hit, but simply returning an internal error response. Will open PR

Comment 2 Juan Vallejo 2017-01-24 20:51:52 UTC
Related PR: https://github.com/openshift/origin/pull/12654

Comment 4 Juan Vallejo 2017-03-22 14:08:44 UTC
@ffranz would this be something we could backport, or is it better to wait until this patch makes it into the next version of ocp?

Comment 5 Fabiano Franz 2017-03-22 21:13:22 UTC
Wasn't this reverted by https://github.com/openshift/origin/commit/91b914e74234a473734162bb7e610859e1103b31 ?

Comment 6 Fabiano Franz 2017-03-22 21:15:26 UTC
It wasn't nevermind.

I think it was supposed to be in v3.5.0.50 already. Anyway it's not going to be backported.

Comment 8 Xingxing Xia 2017-10-26 10:33:41 UTC
(In reply to Nick Schuetz from comment #0)
> 1. oc login <your server with port 443 open but not by OpenShift>
> F1219 09:25:44.993218   39620 helpers.go:110] Error from server: Internal
> error occurred: unexpected response: 503
Trying to install apache/nginx with 443 port on openshift 8443 env. Will continue next day

Comment 9 Xingxing Xia 2017-10-27 08:41:48 UTC
Checked multiple situations in oc/OCP v3.7.0-0.182.0.
Below situations work well:
a. Specify port 8445 not opened in server
$ oc login https://$MASTER:8445
error: dial tcp ...:8445: getsockopt: no route to host - verify you have provided the correct host and port and that the server is currently running

b. Specify port 443 not opened in server
error: dial tcp ...:443: getsockopt: connection refused - verify you have provided the correct host and port and that the server is currently running

Above all include "verify you ... correct host and port ... currently running" as the PR intends

Comment 11 Juan Vallejo 2017-10-27 18:03:48 UTC
Origin PR: https://github.com/openshift/origin/pull/17073

Comment 12 Xingxing Xia 2017-11-01 09:48:05 UTC
Verified in oc v3.7.0-0.189.0 for comment 10, now the errors are appended with "verify ... currently running":
error: json: cannot unmarshal number into Go value of type util.OauthAuthorizationServerMetadata - verify you have provided the correct host and port and that the server is currently running.

error: invalid character '<' looking for beginning of value - verify you have provided the correct host and port and that the server is currently running.