From 16077d91ddfeebe77a3c6d7fedc7125ddff17bdb Mon Sep 17 00:00:00 2001 From: Pawel Koniszewski Date: Wed, 3 Sep 2014 08:58:55 -0400 Subject: [PATCH] Catch new urllib3 exception: ProtocolError The new version of requests (2.4.0) has updated underlying urllib3 to version 1.9. Unfortunately urllib3 introduced new exception ProtocolError. Because of that unit tests in glance are failing: ProtocolError: ('Connection aborted.', gaierror(-2, 'Name or service not known')) To solve this problem new urllib3 exception is caught in the same place that the old one was. Unfortunately both exception are still in use so I couldn't remove the old one. Change-Id: I55eef98e734c59b9b627f182768a633b2b701e43 Closes-Bug: #1364893 --- glanceclient/common/http.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/glanceclient/common/http.py b/glanceclient/common/http.py index 4023f038..8c7937a2 100644 --- a/glanceclient/common/http.py +++ b/glanceclient/common/http.py @@ -18,6 +18,10 @@ import logging import socket import requests +try: + from requests.packages.urllib3.exceptions import ProtocolError +except ImportError: + ProtocolError = requests.exceptions.ConnectionError import six from six.moves.urllib import parse @@ -198,7 +202,7 @@ class HTTPClient(object): message = ("Error communicating with %(endpoint)s %(e)s" % dict(url=conn_url, e=e)) raise exc.InvalidEndpoint(message=message) - except requests.exceptions.ConnectionError as e: + except (requests.exceptions.ConnectionError, ProtocolError) as e: message = ("Error finding address for %(url)s: %(e)s" % dict(url=conn_url, e=e)) raise exc.CommunicationError(message=message)