diff --git a/vmware_nsxlib/v3/debug_retry.py b/vmware_nsxlib/v3/debug_retry.py index f739d120..ca150474 100644 --- a/vmware_nsxlib/v3/debug_retry.py +++ b/vmware_nsxlib/v3/debug_retry.py @@ -18,9 +18,6 @@ from collections import namedtuple import logging import traceback -import six -from urllib3.exceptions import MaxRetryError -from urllib3.exceptions import ResponseError from urllib3.util.retry import Retry log = logging.getLogger(__name__) @@ -37,76 +34,14 @@ class RetryDebug(Retry): def increment(self, method=None, url=None, response=None, error=None, _pool=None, _stacktrace=None, ): - log.debug("Retry Increment %s", traceback.format_stack()) - if self.total is False and error: - # Disabled, indicate to re-raise the error. - raise six.reraise(type(error), error, _stacktrace) - - total = self.total - if total is not None: - total -= 1 - - connect = self.connect - read = self.read - redirect = self.redirect - status_count = self.status - cause = "unknown" - status = None - redirect_location = None - - if error and self._is_connection_error(error): - # Connect retry? - if connect is False: - raise six.reraise(type(error), error, _stacktrace) - elif connect is not None: - connect -= 1 - - elif error and self._is_read_error(error): - # Read retry? - if read is False or not self._is_method_retryable(method): - raise six.reraise(type(error), error, _stacktrace) - elif read is not None: - read -= 1 - - elif response and response.get_redirect_location(): - # Redirect retry? - if redirect is not None: - redirect -= 1 - cause = "too many redirects" - redirect_location = response.get_redirect_location() - status = response.status - + if method == 'PUT': + log.info("Retry Increment %s", traceback.format_stack()) + log.info("Retry url: %s, response: %s, error: %s," + "_stacktrace: %s", url, response, error, _stacktrace) else: - # Incrementing because of a server error like a 500 in - # status_forcelist and a the given method is in the whitelist - cause = ResponseError.GENERIC_ERROR - if response and response.status: - if status_count is not None: - status_count -= 1 - cause = ResponseError.SPECIFIC_ERROR.format( - status_code=response.status) - status = response.status - - history = self.history + ( - RequestHistory(method, url, error, status, redirect_location), - ) - - new_retry = self.new( - total=total, - connect=connect, - read=read, - redirect=redirect, - status=status_count, - history=history, - ) - - if new_retry.is_exhausted(): - raise MaxRetryError(_pool, url, error or ResponseError(cause)) - - # log the cause for this retry - log.debug("Cause for retry: %s", cause) - # log the server response for this retry - log.debug("Response: %s", response) - log.debug("Incremented Retry for (url='%s'): %r", url, new_retry) - - return new_retry + log.debug("Retry Increment %s", traceback.format_stack()) + log.debug("Retry method: %s, url: %s, response: %s, error: %s," + " _stacktrace: %s", method, url, response, error, + _stacktrace) + return super(RetryDebug, self).increment(method, url, response, + error, _pool, _stacktrace)