Save some effort when discovering used_source_etag
Change-Id: I35d682e58419f141429877ac6a6964132f7e658b
This commit is contained in:
parent
f8a6dee622
commit
fe09ef2581
@ -1185,7 +1185,7 @@ class GetOrHeadHandler(GetterBase):
|
|||||||
backend_headers=backend_headers, logger=logger)
|
backend_headers=backend_headers, logger=logger)
|
||||||
self.server_type = server_type
|
self.server_type = server_type
|
||||||
self.used_nodes = []
|
self.used_nodes = []
|
||||||
self.used_source_etag = ''
|
self.used_source_etag = None
|
||||||
self.concurrency = concurrency
|
self.concurrency = concurrency
|
||||||
self.latest_404_timestamp = Timestamp(0)
|
self.latest_404_timestamp = Timestamp(0)
|
||||||
if self.server_type == 'Object':
|
if self.server_type == 'Object':
|
||||||
@ -1498,16 +1498,15 @@ class GetOrHeadHandler(GetterBase):
|
|||||||
for unused_source in self.sources:
|
for unused_source in self.sources:
|
||||||
unused_source.close()
|
unused_source.close()
|
||||||
self.used_nodes.append(source.node)
|
self.used_nodes.append(source.node)
|
||||||
src_headers = dict(
|
|
||||||
(k.lower(), v) for k, v in
|
|
||||||
source.resp.getheaders())
|
|
||||||
|
|
||||||
# Save off the source etag so that, if we lose the connection
|
# Save off the source etag so that, if we lose the connection
|
||||||
# and have to resume from a different node, we can be sure that
|
# and have to resume from a different node, we can be sure that
|
||||||
# we have the same object (replication). Otherwise, if the cluster
|
# we have the same object (replication). Otherwise, if the cluster
|
||||||
# has two versions of the same object, we might end up switching
|
# has two versions of the same object, we might end up switching
|
||||||
# between old and new mid-stream and giving garbage to the client.
|
# between old and new mid-stream and giving garbage to the client.
|
||||||
self.used_source_etag = normalize_etag(src_headers.get('etag', ''))
|
if self.used_source_etag is None:
|
||||||
|
self.used_source_etag = normalize_etag(
|
||||||
|
source.resp.getheader('etag', ''))
|
||||||
self.source = source
|
self.source = source
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -1082,7 +1082,7 @@ class TestProxyServer(unittest.TestCase):
|
|||||||
elif header == "Content-Length":
|
elif header == "Content-Length":
|
||||||
return str(len(body))
|
return str(len(body))
|
||||||
else:
|
else:
|
||||||
return 1
|
return "1"
|
||||||
|
|
||||||
resp = mock.Mock()
|
resp = mock.Mock()
|
||||||
resp.read.side_effect = [body.encode('ascii'), b'']
|
resp.read.side_effect = [body.encode('ascii'), b'']
|
||||||
|
Loading…
Reference in New Issue
Block a user