Save some effort when discovering used_source_etag

Change-Id: I35d682e58419f141429877ac6a6964132f7e658b
This commit is contained in:
Tim Burke 2023-08-04 16:01:32 -07:00 committed by Alistair Coles
parent f8a6dee622
commit fe09ef2581
2 changed files with 5 additions and 6 deletions

View File

@ -1185,7 +1185,7 @@ class GetOrHeadHandler(GetterBase):
backend_headers=backend_headers, logger=logger)
self.server_type = server_type
self.used_nodes = []
self.used_source_etag = ''
self.used_source_etag = None
self.concurrency = concurrency
self.latest_404_timestamp = Timestamp(0)
if self.server_type == 'Object':
@ -1498,16 +1498,15 @@ class GetOrHeadHandler(GetterBase):
for unused_source in self.sources:
unused_source.close()
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
# and have to resume from a different node, we can be sure that
# we have the same object (replication). Otherwise, if the cluster
# has two versions of the same object, we might end up switching
# 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
return True
return False

View File

@ -1082,7 +1082,7 @@ class TestProxyServer(unittest.TestCase):
elif header == "Content-Length":
return str(len(body))
else:
return 1
return "1"
resp = mock.Mock()
resp.read.side_effect = [body.encode('ascii'), b'']