Merge "Replace retrying with tenacity"
This commit is contained in:
commit
db83e3b636
|
@ -13,9 +13,9 @@
|
||||||
|
|
||||||
# SQLAlchemy helper functions
|
# SQLAlchemy helper functions
|
||||||
|
|
||||||
import retrying
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from sqlalchemy.orm import exc
|
from sqlalchemy.orm import exc
|
||||||
|
import tenacity
|
||||||
|
|
||||||
|
|
||||||
def clone_table(name, parent, meta, newcols=None, ignorecols=None,
|
def clone_table(name, parent, meta, newcols=None, ignorecols=None,
|
||||||
|
@ -91,8 +91,8 @@ def migrate_data(migrate_engine,
|
||||||
|
|
||||||
|
|
||||||
def retry_on_stale_data_error(func):
|
def retry_on_stale_data_error(func):
|
||||||
def is_staledata_error(ex):
|
wrapper = tenacity.retry(
|
||||||
return isinstance(ex, exc.StaleDataError)
|
stop=tenacity.stop_after_attempt(3),
|
||||||
wrapper = retrying.retry(stop_max_attempt_number=3,
|
retry=tenacity.retry_if_exception_type(exc.StaleDataError),
|
||||||
retry_on_exception=is_staledata_error)
|
reraise=True)
|
||||||
return wrapper(func)
|
return wrapper(func)
|
||||||
|
|
|
@ -25,9 +25,9 @@ from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
from retrying import retry
|
|
||||||
import six
|
import six
|
||||||
from six.moves.urllib import parse as urlparse
|
from six.moves.urllib import parse as urlparse
|
||||||
|
import tenacity
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
|
@ -116,8 +116,12 @@ class NovaClientPlugin(client_plugin.ClientPlugin):
|
||||||
return (isinstance(ex, exceptions.ClientException) and
|
return (isinstance(ex, exceptions.ClientException) and
|
||||||
http_status == 422)
|
http_status == 422)
|
||||||
|
|
||||||
@retry(stop_max_attempt_number=max(cfg.CONF.client_retry_limit + 1, 0),
|
@tenacity.retry(
|
||||||
retry_on_exception=client_plugin.retry_if_connection_err)
|
stop=tenacity.stop_after_attempt(
|
||||||
|
max(cfg.CONF.client_retry_limit + 1, 0)),
|
||||||
|
retry=tenacity.retry_if_exception(
|
||||||
|
client_plugin.retry_if_connection_err),
|
||||||
|
reraise=True)
|
||||||
def get_server(self, server):
|
def get_server(self, server):
|
||||||
"""Return fresh server object.
|
"""Return fresh server object.
|
||||||
|
|
||||||
|
@ -564,8 +568,12 @@ echo -e '%s\tALL=(ALL)\tNOPASSWD: ALL' >> /etc/sudoers
|
||||||
if len(server.networks[n]) > 0:
|
if len(server.networks[n]) > 0:
|
||||||
return server.networks[n][0]
|
return server.networks[n][0]
|
||||||
|
|
||||||
@retry(stop_max_attempt_number=max(cfg.CONF.client_retry_limit + 1, 0),
|
@tenacity.retry(
|
||||||
retry_on_exception=client_plugin.retry_if_connection_err)
|
stop=tenacity.stop_after_attempt(
|
||||||
|
max(cfg.CONF.client_retry_limit + 1, 0)),
|
||||||
|
retry=tenacity.retry_if_exception(
|
||||||
|
client_plugin.retry_if_connection_err),
|
||||||
|
reraise=True)
|
||||||
def absolute_limits(self):
|
def absolute_limits(self):
|
||||||
"""Return the absolute limits as a dictionary."""
|
"""Return the absolute limits as a dictionary."""
|
||||||
limits = self.client().limits.get()
|
limits = self.client().limits.get()
|
||||||
|
@ -696,9 +704,11 @@ echo -e '%s\tALL=(ALL)\tNOPASSWD: ALL' >> /etc/sudoers
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@retry(stop_max_attempt_number=cfg.CONF.max_interface_check_attempts,
|
@tenacity.retry(
|
||||||
wait_fixed=500,
|
stop=tenacity.stop_after_attempt(
|
||||||
retry_on_result=client_plugin.retry_if_result_is_false)
|
cfg.CONF.max_interface_check_attempts),
|
||||||
|
wait=tenacity.wait_fixed(0.5),
|
||||||
|
retry=tenacity.retry_if_result(client_plugin.retry_if_result_is_false))
|
||||||
def check_interface_detach(self, server_id, port_id):
|
def check_interface_detach(self, server_id, port_id):
|
||||||
server = self.fetch_server(server_id)
|
server = self.fetch_server(server_id)
|
||||||
if server:
|
if server:
|
||||||
|
@ -708,9 +718,11 @@ echo -e '%s\tALL=(ALL)\tNOPASSWD: ALL' >> /etc/sudoers
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@retry(stop_max_attempt_number=cfg.CONF.max_interface_check_attempts,
|
@tenacity.retry(
|
||||||
wait_fixed=500,
|
stop=tenacity.stop_after_attempt(
|
||||||
retry_on_result=client_plugin.retry_if_result_is_false)
|
cfg.CONF.max_interface_check_attempts),
|
||||||
|
wait=tenacity.wait_fixed(0.5),
|
||||||
|
retry=tenacity.retry_if_result(client_plugin.retry_if_result_is_false))
|
||||||
def check_interface_attach(self, server_id, port_id):
|
def check_interface_attach(self, server_id, port_id):
|
||||||
server = self.fetch_server(server_id)
|
server = self.fetch_server(server_id)
|
||||||
if server:
|
if server:
|
||||||
|
|
|
@ -17,7 +17,7 @@ import eventlet
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from oslo_utils import netutils
|
from oslo_utils import netutils
|
||||||
import retrying
|
import tenacity
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
|
@ -431,7 +431,7 @@ class ServerNetworkMixin(object):
|
||||||
'server %(server)s.')
|
'server %(server)s.')
|
||||||
% {'port': port['id'],
|
% {'port': port['id'],
|
||||||
'server': existing_server_id})
|
'server': existing_server_id})
|
||||||
except retrying.RetryError:
|
except tenacity.RetryError:
|
||||||
raise exception.InterfaceDetachFailed(
|
raise exception.InterfaceDetachFailed(
|
||||||
port=port['id'], server=existing_server_id)
|
port=port['id'], server=existing_server_id)
|
||||||
|
|
||||||
|
@ -448,7 +448,7 @@ class ServerNetworkMixin(object):
|
||||||
'server %(server)s')
|
'server %(server)s')
|
||||||
% {'port': port['id'],
|
% {'port': port['id'],
|
||||||
'server': prev_server_id})
|
'server': prev_server_id})
|
||||||
except retrying.RetryError:
|
except tenacity.RetryError:
|
||||||
raise exception.InterfaceAttachFailed(
|
raise exception.InterfaceAttachFailed(
|
||||||
port=port['id'], server=prev_server_id)
|
port=port['id'], server=prev_server_id)
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,8 @@ from oslo_config import cfg
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from oslo_versionedobjects import base
|
from oslo_versionedobjects import base
|
||||||
from oslo_versionedobjects import fields
|
from oslo_versionedobjects import fields
|
||||||
import retrying
|
|
||||||
import six
|
import six
|
||||||
|
import tenacity
|
||||||
|
|
||||||
from heat.common import crypt
|
from heat.common import crypt
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
|
@ -36,11 +36,12 @@ cfg.CONF.import_opt('encrypt_parameters_and_properties', 'heat.common.config')
|
||||||
|
|
||||||
|
|
||||||
def retry_on_conflict(func):
|
def retry_on_conflict(func):
|
||||||
def is_conflict(ex):
|
wrapper = tenacity.retry(
|
||||||
return isinstance(ex, exception.ConcurrentTransaction)
|
stop=tenacity.stop_after_attempt(11),
|
||||||
wrapper = retrying.retry(stop_max_attempt_number=11,
|
wait=tenacity.wait_random(max=0.002),
|
||||||
wait_random_min=0.0, wait_random_max=2.0,
|
retry=tenacity.retry_if_exception_type(
|
||||||
retry_on_exception=is_conflict)
|
exception.ConcurrentTransaction),
|
||||||
|
reraise=True)
|
||||||
return wrapper(func)
|
return wrapper(func)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ python-zaqarclient>=1.0.0 # Apache-2.0
|
||||||
pytz>=2013.6 # MIT
|
pytz>=2013.6 # MIT
|
||||||
PyYAML>=3.10.0 # MIT
|
PyYAML>=3.10.0 # MIT
|
||||||
requests>=2.10.0 # Apache-2.0
|
requests>=2.10.0 # Apache-2.0
|
||||||
retrying!=1.3.0,>=1.2.3 # Apache-2.0
|
tenacity>=3.2.1 # Apache-2.0
|
||||||
Routes!=2.0,!=2.1,!=2.3.0,>=1.12.3;python_version=='2.7' # MIT
|
Routes!=2.0,!=2.1,!=2.3.0,>=1.12.3;python_version=='2.7' # MIT
|
||||||
Routes!=2.0,!=2.3.0,>=1.12.3;python_version!='2.7' # MIT
|
Routes!=2.0,!=2.3.0,>=1.12.3;python_version!='2.7' # MIT
|
||||||
six>=1.9.0 # MIT
|
six>=1.9.0 # MIT
|
||||||
|
|
Loading…
Reference in New Issue