SHARE
TWEET

Untitled

a guest Jun 20th, 2017 525 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. From fb2ad0bb582e7bd2a336f27e4ab59c28c8d8503b Mon Sep 17 00:00:00 2001
  2. From: Balazs Gibizer <balazs.gibizer@ericsson.com>
  3. Date: Tue, 20 Jun 2017 11:57:01 +0000
  4. Subject: [PATCH] Troubleshooting api_fault notification
  5.  
  6. ---
  7. nova/api/openstack/__init__.py   | 10 +++++++++-
  8.  nova/api/openstack/extensions.py |  2 ++
  9.  nova/api/openstack/wsgi.py       | 10 +++++++---
  10.  nova/objects/aggregate.py        |  3 +++
  11.  4 files changed, 21 insertions(+), 4 deletions(-)
  12.  
  13. diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py
  14. index 93aaf6d..60bbedd 100644
  15. --- a/nova/api/openstack/__init__.py
  16. +++ b/nova/api/openstack/__init__.py
  17. @@ -43,11 +43,14 @@ class FaultWrapper(base_wsgi.Middleware):
  18.  
  19.      @staticmethod
  20.      def status_to_type(status):
  21. +        LOG.info('!!! FaultWrapper status_to_type status=%s' % status)
  22.          if not FaultWrapper._status_to_type:
  23.              for clazz in utils.walk_class_hierarchy(webob.exc.HTTPError):
  24.                  FaultWrapper._status_to_type[clazz.code] = clazz
  25. -        return FaultWrapper._status_to_type.get(
  26. +        result = FaultWrapper._status_to_type.get(
  27.                                    status, webob.exc.HTTPInternalServerError)()
  28. +        LOG.info('!!! FaultWrapper status_to_type returns %s' % result)
  29. +        return result
  30.  
  31.      def _error(self, inner, req):
  32.          LOG.exception("Caught error: %s", inner)
  33. @@ -82,8 +85,13 @@ class FaultWrapper(base_wsgi.Middleware):
  34.      @webob.dec.wsgify(RequestClass=wsgi.Request)
  35.      def __call__(self, req):
  36.          try:
  37. +            LOG.info('!!! FaultWrapper __call__')
  38.              return req.get_response(self.application)
  39. +        except webob.exc.HTTPInternalServerError as ex:
  40. +            LOG.info('!!! FaultWrapper ___call__ catches %s' % ex)
  41. +            return self._error(ex, req)
  42.          except Exception as ex:
  43. +            LOG.info('!!! FaultWrapper ___call__ catches %s' % ex)
  44.              return self._error(ex, req)
  45.  
  46.  
  47. diff --git a/nova/api/openstack/extensions.py b/nova/api/openstack/extensions.py
  48. index 8dbb1b6..17c152b 100644
  49. --- a/nova/api/openstack/extensions.py
  50. +++ b/nova/api/openstack/extensions.py
  51. @@ -335,6 +335,7 @@ def expected_errors(errors):
  52.              try:
  53.                  return f(*args, **kwargs)
  54.              except Exception as exc:
  55. +                LOG.info('!!! expected_errors catching %s' % exc)
  56.                  if isinstance(exc, webob.exc.WSGIHTTPException):
  57.                      if isinstance(errors, int):
  58.                          t_errors = (errors,)
  59. @@ -365,6 +366,7 @@ def expected_errors(errors):
  60.                  msg = _('Unexpected API Error. Please report this at '
  61.                      'http://bugs.launchpad.net/nova/ and attach the Nova '
  62.                      'API log if possible.\n%s') % type(exc)
  63. +                LOG.info('!!! expected_errors raising HTTPInternalServerError')
  64.                  raise webob.exc.HTTPInternalServerError(explanation=msg)
  65.  
  66.          return wrapped
  67. diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py
  68. index 0cc7b70..aadfc9d 100644
  69. --- a/nova/api/openstack/wsgi.py
  70. +++ b/nova/api/openstack/wsgi.py
  71. @@ -395,7 +395,7 @@ class ResourceExceptionHandler(object):
  72.      def __exit__(self, ex_type, ex_value, ex_traceback):
  73.          if not ex_value:
  74.              return True
  75. -
  76. +        LOG.info('!!! ResouceExceptionHandler.__exit__ runs with ex_type=%s ex_value=%s, ex_traceback=%s' %(ex_type, ex_value, ex_traceback))
  77.          if isinstance(ex_value, exception.Forbidden):
  78.              raise Fault(webob.exc.HTTPForbidden(
  79.                      explanation=ex_value.format_message()))
  80. @@ -414,9 +414,10 @@ class ResourceExceptionHandler(object):
  81.              LOG.info("Fault thrown: %s", ex_value)
  82.              raise ex_value
  83.          elif isinstance(ex_value, webob.exc.HTTPException):
  84. -            LOG.info("HTTP exception thrown: %s", ex_value)
  85. +            LOG.info("!!! HTTP exception thrown: %s", ex_value)
  86.              raise Fault(ex_value)
  87.  
  88. +        LOG.info('!!! ResourceExceptionHandler.__exit__ didnt translate the exception and order the context to raise the original exception again.')
  89.          # We didn't handle the exception
  90.          return False
  91.  
  92. @@ -592,6 +593,7 @@ class Resource(wsgi.Application):
  93.          try:
  94.              meth, extensions = self.get_method(request, action,
  95.                                                 content_type, body)
  96. +            LOG.info('!!! Resouce._process_stack method=%s, extensions=%s' %(meth, extensions))
  97.          except (AttributeError, TypeError):
  98.              return Fault(webob.exc.HTTPNotFound())
  99.          except KeyError as ex:
  100. @@ -634,8 +636,10 @@ class Resource(wsgi.Application):
  101.          response = None
  102.          try:
  103.              with ResourceExceptionHandler():
  104. +                LOG.info('!!! _process_stack calls dispatch')
  105.                  action_result = self.dispatch(meth, request, action_args)
  106.          except Fault as ex:
  107. +            LOG.info('!!! _process_stack catches Fault exception')
  108.              response = ex
  109.  
  110.          if not response:
  111. @@ -891,7 +895,7 @@ class Controller(object):
  112.          if version_meth_dict and \
  113.            key in object.__getattribute__(self, VER_METHOD_ATTR):
  114.              return version_select
  115. -
  116. +        LOG.info('!!! wsgi.Controller __getattribute__ key=%s' % key)
  117.          return object.__getattribute__(self, key)
  118.  
  119.      # NOTE(cyeoh): This decorator MUST appear first (the outermost
  120. diff --git a/nova/objects/aggregate.py b/nova/objects/aggregate.py
  121. index 7f34c06..becc3ec 100644
  122. --- a/nova/objects/aggregate.py
  123. +++ b/nova/objects/aggregate.py
  124. @@ -323,6 +323,9 @@ class Aggregate(base.NovaPersistentObject, base.NovaObject):
  125.  
  126.      @base.remotable
  127.      def create(self):
  128. +        LOG.info('!!! aggregate.create called and will fail')
  129. +        raise ValueError()
  130. +
  131.          if self.obj_attr_is_set('id'):
  132.              raise exception.ObjectActionError(action='create',
  133.                                                reason='already created')
  134. --
  135. 2.7.4
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top