Browse Source

be more explicit about connection errors

urllib/requests ConnectionError is a translation of
SocketError. However, when we translate this *yet again* we drop the
message from Requests. That message contains the actual SocketError
details, which are often critical for debugging an issue.

This keeps those details in the error message as we carry this up.

Change-Id: I6b753fddaebdcbcfe62680585a5b6febf62647b3
(cherry picked from commit 7d26de17f5)
Sean Dague 2 years ago
parent
commit
e8a06de989
1 changed files with 8 additions and 2 deletions
  1. 8
    2
      keystoneauth1/session.py

+ 8
- 2
keystoneauth1/session.py View File

@@ -491,8 +491,14 @@ class Session(object):
491 491
             except requests.exceptions.Timeout:
492 492
                 msg = 'Request to %s timed out' % url
493 493
                 raise exceptions.ConnectTimeout(msg)
494
-            except requests.exceptions.ConnectionError:
495
-                msg = 'Unable to establish connection to %s' % url
494
+            except requests.exceptions.ConnectionError as e:
495
+                # NOTE(sdague): urllib3/requests connection error is a
496
+                # translation of SocketError. However, SocketError
497
+                # happens for many different reasons, and that low
498
+                # level message is often really important in figuring
499
+                # out the difference between network misconfigurations
500
+                # and firewall blocking.
501
+                msg = 'Unable to establish connection to %s: %s' % (url, e)
496 502
                 raise exceptions.ConnectFailure(msg)
497 503
             except requests.exceptions.RequestException as e:
498 504
                 msg = 'Unexpected exception for %(url)s: %(error)s' % {

Loading…
Cancel
Save