diff options
author | Julien Danjou <julien@danjou.info> | 2016-06-07 15:49:32 +0200 |
---|---|---|
committer | Julien Danjou <julien@danjou.info> | 2016-06-07 16:58:26 +0200 |
commit | a62b7ee06c1a300c73d9a01b2c9bc05028f1fabd (patch) | |
tree | ecaa70376eeec43488af354d5883d3cc3ef4d34a /swiftclient/client.py | |
parent | c91c8d575e86b480270f8dfb7df49355dd38ee54 (diff) | |
download | python-swiftclient-a62b7ee06c1a300c73d9a01b2c9bc05028f1fabd.tar.gz |
client: renew token on 401 even if retries is 0
Gnocchi uses a client with retries=0 to maximize throughtput and not retry N
times on e.g. 404 when checking existence of an object. However, this as the
side effect of never renewing the token since there' no retry on 401 either.
This patches change the behavior so that 401 errors are always retried,
whatever the retries value is.
Closes-Bug: #1589926
Change-Id: Ie06adf4cf17ea4592b5bbd7bbde9828e5e134e3e
Diffstat (limited to 'swiftclient/client.py')
-rw-r--r-- | swiftclient/client.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/swiftclient/client.py b/swiftclient/client.py index 744a876..f556afd 100644 --- a/swiftclient/client.py +++ b/swiftclient/client.py @@ -1544,7 +1544,7 @@ class Connection(object): backoff = self.starting_backoff caller_response_dict = kwargs.pop('response_dict', None) self.attempts = kwargs.pop('attempts', 0) - while self.attempts <= self.retries: + while self.attempts <= self.retries or retried_auth: self.attempts += 1 try: if not self.url or not self.token: @@ -1573,9 +1573,6 @@ class Connection(object): self.http_conn = None except ClientException as err: self._add_response_dict(caller_response_dict, kwargs) - if self.attempts > self.retries or err.http_status is None: - logger.exception(err) - raise if err.http_status == 401: self.url = self.token = self.service_token = None if retried_auth or not all((self.authurl, @@ -1584,6 +1581,9 @@ class Connection(object): logger.exception(err) raise retried_auth = True + elif self.attempts > self.retries or err.http_status is None: + logger.exception(err) + raise elif err.http_status == 408: self.http_conn = None elif 500 <= err.http_status <= 599: |