Commit 77e1d753 authored by Iustin Pop's avatar Iustin Pop
Browse files

Make RAPI return 502/504 errors for luxi errors

This changes the RAPI error codes for luxi errors; a timeout error is
now reported properly as 504, while any other luxi error is reported as

It would be good to convert even more errors into proper return codes in
the future.

Reviewed-by: imsnah
parent 6bb258a7
......@@ -35,6 +35,7 @@ from ganeti import http
from ganeti import daemon
from ganeti import ssconf
from ganeti import utils
from ganeti import luxi
from ganeti.rapi import connector
import ganeti.http.auth
......@@ -144,6 +145,10 @@ class RemoteApiHttpServer(http.auth.HttpServerRequestAuthentication,
sn = ctx.handler.getSerialNumber()
if sn:
req.response_headers[http.HTTP_ETAG] = str(sn)
except luxi.TimeoutError:
raise http.HttpGatewayTimeout()
except luxi.ProtocolError, err:
raise http.HttpBadGateway(str(err))
method = req.request_method.upper()
logging.exception("Error while handling the %s request", method)
......@@ -255,6 +255,17 @@ class HttpNotImplemented(HttpException):
code = 501
class HttpBadGateway(HttpException):
"""502 Bad Gateway
RFC2616, 10.5.3: The server, while acting as a gateway or proxy,
received an invalid response from the upstream server it accessed in
attempting to fulfill the request.
code = 502
class HttpServiceUnavailable(HttpException):
"""503 Service Unavailable
......@@ -265,6 +276,19 @@ class HttpServiceUnavailable(HttpException):
code = 503
class HttpGatewayTimeout(HttpException):
"""504 Gateway Timeout
RFC2616, 10.5.5: The server, while acting as a gateway or proxy, did
not receive a timely response from the upstream server specified by
the URI (e.g. HTTP, FTP, LDAP) or some other auxiliary server
(e.g. DNS) it needed to access in attempting to complete the
code = 504
class HttpVersionNotSupported(HttpException):
"""505 HTTP Version Not Supported
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment