]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Add oslo db retry decorator to non-CRUD actions
authorKevin Benton <blak111@gmail.com>
Thu, 16 Jul 2015 09:07:48 +0000 (02:07 -0700)
committerIhar Hrachyshka <ihrachys@redhat.com>
Thu, 16 Jul 2015 09:26:36 +0000 (11:26 +0200)
The previously added decorators to the create and update handlers
in the API layer only applied to actions that followed the standard
create/update path. However, for API operations like add_router_interface,
a different path is followed that wasn't covered by a retry decorator.

This patch adds the decorator to handle deadlocks in those operations as
well.

Closes-Bug: #1475218
Change-Id: Ib354074e6a3f68cedb95fd774f905d94ca16a830
(cherry picked from commit 435ffa7c67cf8668063588e2af760c1ff595dfbb)

neutron/api/v2/base.py

index 48dea6bf6d0e9e1dd5463ea266beea6ff175b6ac..32cdf26210ddd49291dacb80fcefaab8217a9293 100644 (file)
@@ -187,6 +187,8 @@ class Controller(object):
 
     def __getattr__(self, name):
         if name in self._member_actions:
+            @oslo_db_api.wrap_db_retry(max_retries=db_api.MAX_RETRIES,
+                                       retry_on_deadlock=True)
             def _handle_action(request, id, **kwargs):
                 arg_list = [request.context, id]
                 # Ensure policy engine is initialized
@@ -197,7 +199,7 @@ class Controller(object):
                 except oslo_policy.PolicyNotAuthorized:
                     msg = _('The resource could not be found.')
                     raise webob.exc.HTTPNotFound(msg)
-                body = kwargs.pop('body', None)
+                body = copy.deepcopy(kwargs.pop('body', None))
                 # Explicit comparison with None to distinguish from {}
                 if body is not None:
                     arg_list.append(body)