From dd7c7d6c498cf1048ee8faa9269df9aa087394e9 Mon Sep 17 00:00:00 2001 From: Eric K Date: Fri, 3 Aug 2018 17:11:17 -0700 Subject: [PATCH] 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 --- congress/dse2/dse_node.py | 2 +- congress/exception.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/congress/dse2/dse_node.py b/congress/dse2/dse_node.py index a9744e8d0..f36832c50 100644 --- a/congress/dse2/dse_node.py +++ b/congress/dse2/dse_node.py @@ -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 diff --git a/congress/exception.py b/congress/exception.py index 1278da752..2501109da 100644 --- a/congress/exception.py +++ b/congress/exception.py @@ -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.")