From 86a8a5a2091dc0a36ccbe05f46609c82b1060291 Mon Sep 17 00:00:00 2001 From: Michael Gundlach Date: Tue, 19 Oct 2010 19:37:42 -0400 Subject: Fixes https://bugs.launchpad.net/nova/+bug/663551 by catching exceptions at the top level of the API and turning them into Faults. --- nova/api/openstack/__init__.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'nova/api') diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py index 5706dbc09..24e1dd090 100644 --- a/nova/api/openstack/__init__.py +++ b/nova/api/openstack/__init__.py @@ -23,6 +23,7 @@ WSGI middleware for OpenStack API controllers. import json import time +import logging import routes import webob.dec import webob.exc @@ -53,6 +54,16 @@ class API(wsgi.Middleware): app = AuthMiddleware(RateLimitingMiddleware(APIRouter())) super(API, self).__init__(app) + @webob.dec.wsgify + def __call__(self, req): + try: + return req.get_response(self.application) + except Exception as ex: + logging.warn("Caught error: %s" % str(ex)) + exc = webob.exc.HTTPInternalServerError(explanation=str(ex)) + return faults.Fault(exc) + + class AuthMiddleware(wsgi.Middleware): """Authorize the openstack API request or return an HTTP Forbidden.""" -- cgit From e2746b3e4a3e07b6eea6c3db1551d4d61f2e0a97 Mon Sep 17 00:00:00 2001 From: Michael Gundlach Date: Mon, 25 Oct 2010 12:23:55 -0400 Subject: pep8 --- nova/api/openstack/ratelimiting/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nova/api') diff --git a/nova/api/openstack/ratelimiting/__init__.py b/nova/api/openstack/ratelimiting/__init__.py index 9e028ecf5..918caf055 100644 --- a/nova/api/openstack/ratelimiting/__init__.py +++ b/nova/api/openstack/ratelimiting/__init__.py @@ -68,10 +68,10 @@ class Limiter(object): self._levels[key] = (now, new_level) return None - # If one instance of this WSGIApps is unable to handle your load, put a # sharding app in front that shards by username to one of many backends. + class WSGIApp(object): """Application that tracks rate limits in memory. Send requests to it of -- cgit