From bcb4d237a79be9af18f1bcc792e1827c18b058d2 Mon Sep 17 00:00:00 2001 From: Kevin Benton Date: Thu, 16 Jul 2015 02:07:48 -0700 Subject: [PATCH] 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) --- neutron/api/v2/base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) -- 2.45.2