Merge "Add oslo db retry decorator to non-CRUD actions"
This commit is contained in:
commit
79e8a219eb
@ -17,7 +17,6 @@ import copy
|
||||
|
||||
import netaddr
|
||||
from oslo_config import cfg
|
||||
from oslo_db import api as oslo_db_api
|
||||
from oslo_log import log as logging
|
||||
from oslo_policy import policy as oslo_policy
|
||||
from oslo_utils import excutils
|
||||
@ -187,6 +186,7 @@ class Controller(object):
|
||||
|
||||
def __getattr__(self, name):
|
||||
if name in self._member_actions:
|
||||
@db_api.retry_db_errors
|
||||
def _handle_action(request, id, **kwargs):
|
||||
arg_list = [request.context, id]
|
||||
# Ensure policy engine is initialized
|
||||
@ -197,7 +197,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)
|
||||
@ -383,8 +383,7 @@ class Controller(object):
|
||||
# We need a way for ensuring that if it has been created,
|
||||
# it is then deleted
|
||||
|
||||
@oslo_db_api.wrap_db_retry(max_retries=db_api.MAX_RETRIES,
|
||||
retry_on_deadlock=True)
|
||||
@db_api.retry_db_errors
|
||||
def create(self, request, body=None, **kwargs):
|
||||
"""Creates a new instance of the requested entity."""
|
||||
parent_id = kwargs.get(self._parent_id_name)
|
||||
@ -473,8 +472,7 @@ class Controller(object):
|
||||
return notify({self._resource: self._view(request.context,
|
||||
obj)})
|
||||
|
||||
@oslo_db_api.wrap_db_retry(max_retries=db_api.MAX_RETRIES,
|
||||
retry_on_deadlock=True)
|
||||
@db_api.retry_db_errors
|
||||
def delete(self, request, id, **kwargs):
|
||||
"""Deletes the specified entity."""
|
||||
self._notifier.info(request.context,
|
||||
@ -509,8 +507,7 @@ class Controller(object):
|
||||
result,
|
||||
notifier_method)
|
||||
|
||||
@oslo_db_api.wrap_db_retry(max_retries=db_api.MAX_RETRIES,
|
||||
retry_on_deadlock=True)
|
||||
@db_api.retry_db_errors
|
||||
def update(self, request, id, body=None, **kwargs):
|
||||
"""Updates the specified entity's attributes."""
|
||||
parent_id = kwargs.get(self._parent_id_name)
|
||||
|
@ -17,6 +17,7 @@ import contextlib
|
||||
import six
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_db import api as oslo_db_api
|
||||
from oslo_db import exception as os_db_exception
|
||||
from oslo_db.sqlalchemy import session
|
||||
from sqlalchemy import exc
|
||||
@ -26,6 +27,8 @@ from sqlalchemy import orm
|
||||
_FACADE = None
|
||||
|
||||
MAX_RETRIES = 10
|
||||
retry_db_errors = oslo_db_api.wrap_db_retry(max_retries=MAX_RETRIES,
|
||||
retry_on_deadlock=True)
|
||||
|
||||
|
||||
def _create_facade_lazily():
|
||||
|
Loading…
x
Reference in New Issue
Block a user