Merge "Internal Client should only retry server errors"
This commit is contained in:
commit
f2aed004a0
@ -26,11 +26,10 @@ from time import gmtime, strftime, time
|
|||||||
from zlib import compressobj
|
from zlib import compressobj
|
||||||
|
|
||||||
from swift.common.exceptions import ClientException
|
from swift.common.exceptions import ClientException
|
||||||
from swift.common.http import HTTP_NOT_FOUND, HTTP_MULTIPLE_CHOICES, \
|
from swift.common.http import (HTTP_NOT_FOUND, HTTP_MULTIPLE_CHOICES,
|
||||||
HTTP_CONFLICT
|
is_server_error)
|
||||||
from swift.common.swob import Request
|
from swift.common.swob import Request
|
||||||
from swift.common.utils import quote, closing_if_possible, \
|
from swift.common.utils import quote, closing_if_possible
|
||||||
server_handled_successfully
|
|
||||||
from swift.common.wsgi import loadapp, pipeline_property
|
from swift.common.wsgi import loadapp, pipeline_property
|
||||||
|
|
||||||
if six.PY3:
|
if six.PY3:
|
||||||
@ -199,14 +198,9 @@ class InternalClient(object):
|
|||||||
if resp.status_int in acceptable_statuses or \
|
if resp.status_int in acceptable_statuses or \
|
||||||
resp.status_int // 100 in acceptable_statuses:
|
resp.status_int // 100 in acceptable_statuses:
|
||||||
return resp
|
return resp
|
||||||
elif server_handled_successfully(resp.status_int):
|
elif not is_server_error(resp.status_int):
|
||||||
# No sense retrying when we expect the same result
|
# No sense retrying when we expect the same result
|
||||||
break
|
break
|
||||||
elif resp.status_int == HTTP_CONFLICT and 'x-timestamp' in [
|
|
||||||
header.lower() for header in headers]:
|
|
||||||
# Since the caller provided the timestamp, retrying won't
|
|
||||||
# change the result
|
|
||||||
break
|
|
||||||
# sleep only between tries, not after each one
|
# sleep only between tries, not after each one
|
||||||
if attempt < self.request_tries - 1:
|
if attempt < self.request_tries - 1:
|
||||||
if resp:
|
if resp:
|
||||||
|
@ -464,7 +464,7 @@ class TestInternalClient(unittest.TestCase):
|
|||||||
|
|
||||||
# Since we didn't provide an X-Timestamp, retrying gives us a chance to
|
# Since we didn't provide an X-Timestamp, retrying gives us a chance to
|
||||||
# succeed (assuming the failure was due to clock skew between servers)
|
# succeed (assuming the failure was due to clock skew between servers)
|
||||||
expected = (' HTTP/1.0 409 ', ' HTTP/1.0 409 ', ' HTTP/1.0 409 ', )
|
expected = (' HTTP/1.0 409 ',)
|
||||||
loglines = client.logger.get_lines_for_level('info')
|
loglines = client.logger.get_lines_for_level('info')
|
||||||
for expected, logline in izip_longest(expected, loglines):
|
for expected, logline in izip_longest(expected, loglines):
|
||||||
if not expected:
|
if not expected:
|
||||||
|
Loading…
Reference in New Issue
Block a user