From: Kevin Benton Date: Thu, 16 Jul 2015 09:07:48 +0000 (-0700) Subject: Add oslo db retry decorator to non-CRUD actions X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=bcb4d237a79be9af18f1bcc792e1827c18b058d2;p=openstack-build%2Fneutron-build.git Add oslo db retry decorator to non-CRUD actions 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) --- diff --git a/neutron/api/v2/base.py b/neutron/api/v2/base.py index 48dea6bf6..32cdf2621 100644 --- a/neutron/api/v2/base.py +++ b/neutron/api/v2/base.py @@ -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)