Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From fb2ad0bb582e7bd2a336f27e4ab59c28c8d8503b Mon Sep 17 00:00:00 2001
- From: Balazs Gibizer <balazs.gibizer@ericsson.com>
- Date: Tue, 20 Jun 2017 11:57:01 +0000
- Subject: [PATCH] Troubleshooting api_fault notification
- ---
- nova/api/openstack/__init__.py | 10 +++++++++-
- nova/api/openstack/extensions.py | 2 ++
- nova/api/openstack/wsgi.py | 10 +++++++---
- nova/objects/aggregate.py | 3 +++
- 4 files changed, 21 insertions(+), 4 deletions(-)
- diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py
- index 93aaf6d..60bbedd 100644
- --- a/nova/api/openstack/__init__.py
- +++ b/nova/api/openstack/__init__.py
- @@ -43,11 +43,14 @@ class FaultWrapper(base_wsgi.Middleware):
- @staticmethod
- def status_to_type(status):
- + LOG.info('!!! FaultWrapper status_to_type status=%s' % status)
- if not FaultWrapper._status_to_type:
- for clazz in utils.walk_class_hierarchy(webob.exc.HTTPError):
- FaultWrapper._status_to_type[clazz.code] = clazz
- - return FaultWrapper._status_to_type.get(
- + result = FaultWrapper._status_to_type.get(
- status, webob.exc.HTTPInternalServerError)()
- + LOG.info('!!! FaultWrapper status_to_type returns %s' % result)
- + return result
- def _error(self, inner, req):
- LOG.exception("Caught error: %s", inner)
- @@ -82,8 +85,13 @@ class FaultWrapper(base_wsgi.Middleware):
- @webob.dec.wsgify(RequestClass=wsgi.Request)
- def __call__(self, req):
- try:
- + LOG.info('!!! FaultWrapper __call__')
- return req.get_response(self.application)
- + except webob.exc.HTTPInternalServerError as ex:
- + LOG.info('!!! FaultWrapper ___call__ catches %s' % ex)
- + return self._error(ex, req)
- except Exception as ex:
- + LOG.info('!!! FaultWrapper ___call__ catches %s' % ex)
- return self._error(ex, req)
- diff --git a/nova/api/openstack/extensions.py b/nova/api/openstack/extensions.py
- index 8dbb1b6..17c152b 100644
- --- a/nova/api/openstack/extensions.py
- +++ b/nova/api/openstack/extensions.py
- @@ -335,6 +335,7 @@ def expected_errors(errors):
- try:
- return f(*args, **kwargs)
- except Exception as exc:
- + LOG.info('!!! expected_errors catching %s' % exc)
- if isinstance(exc, webob.exc.WSGIHTTPException):
- if isinstance(errors, int):
- t_errors = (errors,)
- @@ -365,6 +366,7 @@ def expected_errors(errors):
- msg = _('Unexpected API Error. Please report this at '
- 'http://bugs.launchpad.net/nova/ and attach the Nova '
- 'API log if possible.\n%s') % type(exc)
- + LOG.info('!!! expected_errors raising HTTPInternalServerError')
- raise webob.exc.HTTPInternalServerError(explanation=msg)
- return wrapped
- diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py
- index 0cc7b70..aadfc9d 100644
- --- a/nova/api/openstack/wsgi.py
- +++ b/nova/api/openstack/wsgi.py
- @@ -395,7 +395,7 @@ class ResourceExceptionHandler(object):
- def __exit__(self, ex_type, ex_value, ex_traceback):
- if not ex_value:
- return True
- -
- + LOG.info('!!! ResouceExceptionHandler.__exit__ runs with ex_type=%s ex_value=%s, ex_traceback=%s' %(ex_type, ex_value, ex_traceback))
- if isinstance(ex_value, exception.Forbidden):
- raise Fault(webob.exc.HTTPForbidden(
- explanation=ex_value.format_message()))
- @@ -414,9 +414,10 @@ class ResourceExceptionHandler(object):
- LOG.info("Fault thrown: %s", ex_value)
- raise ex_value
- elif isinstance(ex_value, webob.exc.HTTPException):
- - LOG.info("HTTP exception thrown: %s", ex_value)
- + LOG.info("!!! HTTP exception thrown: %s", ex_value)
- raise Fault(ex_value)
- + LOG.info('!!! ResourceExceptionHandler.__exit__ didnt translate the exception and order the context to raise the original exception again.')
- # We didn't handle the exception
- return False
- @@ -592,6 +593,7 @@ class Resource(wsgi.Application):
- try:
- meth, extensions = self.get_method(request, action,
- content_type, body)
- + LOG.info('!!! Resouce._process_stack method=%s, extensions=%s' %(meth, extensions))
- except (AttributeError, TypeError):
- return Fault(webob.exc.HTTPNotFound())
- except KeyError as ex:
- @@ -634,8 +636,10 @@ class Resource(wsgi.Application):
- response = None
- try:
- with ResourceExceptionHandler():
- + LOG.info('!!! _process_stack calls dispatch')
- action_result = self.dispatch(meth, request, action_args)
- except Fault as ex:
- + LOG.info('!!! _process_stack catches Fault exception')
- response = ex
- if not response:
- @@ -891,7 +895,7 @@ class Controller(object):
- if version_meth_dict and \
- key in object.__getattribute__(self, VER_METHOD_ATTR):
- return version_select
- -
- + LOG.info('!!! wsgi.Controller __getattribute__ key=%s' % key)
- return object.__getattribute__(self, key)
- # NOTE(cyeoh): This decorator MUST appear first (the outermost
- diff --git a/nova/objects/aggregate.py b/nova/objects/aggregate.py
- index 7f34c06..becc3ec 100644
- --- a/nova/objects/aggregate.py
- +++ b/nova/objects/aggregate.py
- @@ -323,6 +323,9 @@ class Aggregate(base.NovaPersistentObject, base.NovaObject):
- @base.remotable
- def create(self):
- + LOG.info('!!! aggregate.create called and will fail')
- + raise ValueError()
- +
- if self.obj_attr_is_set('id'):
- raise exception.ObjectActionError(action='create',
- reason='already created')
- --
- 2.7.4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement