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
Sean Dague 2 years ago
parent
commit
10ba290b00
1 changed files with 8 additions and 2 deletions
  1. 8
    2
      keystoneauth1/session.py

+ 8
- 2
keystoneauth1/session.py View File

@@ -594,8 +594,14 @@ class Session(object):
594 594
             except requests.exceptions.Timeout:
595 595
                 msg = 'Request to %s timed out' % url
596 596
                 raise exceptions.ConnectTimeout(msg)
597
-            except requests.exceptions.ConnectionError:
598
-                msg = 'Unable to establish connection to %s' % url
597
+            except requests.exceptions.ConnectionError as e:
598
+                # NOTE(sdague): urllib3/requests connection error is a
599
+                # translation of SocketError. However, SocketError
600
+                # happens for many different reasons, and that low
601
+                # level message is often really important in figuring
602
+                # out the difference between network misconfigurations
603
+                # and firewall blocking.
604
+                msg = 'Unable to establish connection to %s: %s' % (url, e)
599 605
                 raise exceptions.ConnectFailure(msg)
600 606
             except requests.exceptions.RequestException as e:
601 607
                 msg = 'Unexpected exception for %(url)s: %(error)s' % {

Loading…
Cancel
Save