core: properly report 502 errors for gevent and gunicorn.

- gevent+gunicorn doesn't raise normal pycurl errors
This commit is contained in:
Marcin Kuzminski 2018-02-09 10:52:58 +01:00
parent 0db43a1ca4
commit 141575541f
2 changed files with 8 additions and 0 deletions

View file

@ -132,6 +132,7 @@ class VCSServerUnavailable(HTTPBadGateway):
'Incorrect vcs.server=host:port',
'Incorrect vcs.server.protocol',
]
def __init__(self, message=''):
self.explanation = 'Could not connect to VCS Server'
if message:

View file

@ -197,6 +197,13 @@ def _remote_call(url, payload, exceptions_map, session):
response = session.post(url, data=msgpack.packb(payload))
except pycurl.error as e:
raise exceptions.HttpVCSCommunicationError(e)
except Exception as e:
message = getattr(e, 'message', '')
if 'Failed to connect' in message:
# gevent doesn't return proper pycurl errors
raise exceptions.HttpVCSCommunicationError(e)
else:
raise
if response.status_code >= 400:
log.error('Call to %s returned non 200 HTTP code: %s',