Return 503 if engine overloaded/unresponsive

When the policy engine is present, but an RPC call to it in the
course of fulfilling an API request times out, the error code
returned to the API caller is 404 rather than the more
appropriate 503 (service (temporarily) unavailable).

Change-Id: I5545500ff1c1a4b6e846b810319ad52218ed70fa
Closes-Bug: 1785345
This commit is contained in:
Eric K 2018-08-03 17:11:17 -07:00
parent 5276a6d4ba
commit dd7c7d6c49
2 changed files with 6 additions and 1 deletions

View File

@ -334,7 +334,7 @@ class DseNode(object):
except (messaging_exceptions.MessagingTimeout,
messaging_exceptions.MessageDeliveryFailure):
msg = "Request to service '%s' timed out"
raise exception.NotFound(msg % service_id)
raise exception.Unavailable(msg % service_id)
LOG.trace("<%s> RPC call returned: %s", self.node_id, result)
return result

View File

@ -132,6 +132,11 @@ class NotFound(CongressException):
code = 404
class Unavailable(CongressException):
msg_fmt = _("Service Unavailable.")
code = 503
class PolicyNotAuthorized(Forbidden):
msg_fmt = _("Policy doesn't allow %(action)s to be performed.")