summaryrefslogtreecommitdiff
path: root/ironic/common/glance_service
diff options
context:
space:
mode:
authorBoden R <bodenvmw@gmail.com>2016-09-26 09:26:10 -0600
committerRiccardo Pittau <elfosardo@gmail.com>2021-02-15 17:11:33 +0100
commitb0607a26687c55548af111b128e49dd1e625ba9f (patch)
treeac9a588e23e00fc4368d37b5b90c4d37b11d5a4c /ironic/common/glance_service
parent71ebba5cf354e3c22991764899d0669dd4be04e6 (diff)
downloadironic-b0607a26687c55548af111b128e49dd1e625ba9f.tar.gz
Replace retrying with tenacity
We are replacing all usages of the 'retrying' package with 'tenacity' as the author of retrying is not actively maintaining the project. Unit tests will be added/removed where applicable. Tenacity [1] is a fork of retrying, but has improved the interface and extensibility. Our end goal here is removing the retrying package from our requirements. Tenacity provides the same functionality as retrying, but has the following major differences to account for: - Tenacity uses seconds rather than ms as retrying did. - Tenacity has different kwargs for the decorator and Retrying class itself. - Tenacity has a different approach for retrying args by using classes for its stop/wait/retry kwargs. - By default tenacity raises a RetryError if a retried callable times out; retrying raises the last exception from the callable. Tenacity provides backwards compatibility here by offering the 'reraise' kwarg. - For retries that check a result, tenacity will raise if the retried function raises, whereas retrying retried on all exceptions. [1] https://github.com/jd/tenacity Co-Authored-By: Dmitry Tantsur <dtantsur@protonmail.com> Co-Authored-By: Riccardo Pittau <elfosardo@gmail.com> Story: #1635390 Task: #10528 Change-Id: Ie5eb3ddc196505e8f58ed14de9952284598586fb
Diffstat (limited to 'ironic/common/glance_service')
-rw-r--r--ironic/common/glance_service/image_service.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/ironic/common/glance_service/image_service.py b/ironic/common/glance_service/image_service.py
index 3f9ae3187..68efe46b4 100644
--- a/ironic/common/glance_service/image_service.py
+++ b/ironic/common/glance_service/image_service.py
@@ -25,9 +25,9 @@ from glanceclient import client
from glanceclient import exc as glance_exc
from oslo_log import log
from oslo_utils import uuidutils
-import retrying
import sendfile
from swiftclient import utils as swift_utils
+import tenacity
from ironic.common import exception
from ironic.common.glance_service import service_utils
@@ -112,11 +112,12 @@ class GlanceImageService(object):
self.context = context
self.endpoint = None
- @retrying.retry(
- stop_max_attempt_number=CONF.glance.num_retries + 1,
- retry_on_exception=lambda e: isinstance(
- e, exception.GlanceConnectionFailed),
- wait_fixed=1000
+ @tenacity.retry(
+ retry=tenacity.retry_if_exception_type(
+ exception.GlanceConnectionFailed),
+ stop=tenacity.stop_after_attempt(CONF.glance.num_retries + 1),
+ wait=tenacity.wait_fixed(1),
+ reraise=True
)
def call(self, method, *args, **kwargs):
"""Call a glance client method.
@@ -124,7 +125,6 @@ class GlanceImageService(object):
If we get a connection error,
retry the request according to CONF.num_retries.
- :param context: The request context, for access checks.
:param method: The method requested to be called.
:param args: A list of positional arguments for the method called
:param kwargs: A dict of keyword arguments for the method called