Make X-Backend-Replication consistent for HEAD

Current an X-Backend-Replication GET request for an expired object will
still open the expired datafile and return the object, but HEAD request
with the same headers will 404.  This can lead to some bad assumptions
in probetests and other places where we make direct HEAD requests

N.B. Because SSYNC replication does not make any HEAD requests this
change is immaterial to the correctness of the consistency engine.

Related-Change-Id: I7f90b732c3268cb852b64f17555c631d668044a8
Change-Id: Idc01970b37d1b77e1d48f9c4f4979f63ee771093
This commit is contained in:
Clay Gerrard 2017-08-25 14:15:03 -07:00
parent 87340e5f29
commit 2e0ca543e8
2 changed files with 15 additions and 9 deletions

View File

@ -972,7 +972,9 @@ class ObjectController(BaseStorageServer):
try:
disk_file = self.get_diskfile(
device, partition, account, container, obj,
policy=policy, frag_prefs=frag_prefs)
policy=policy, frag_prefs=frag_prefs,
open_expired=config_true_value(
request.headers.get('x-backend-replication', 'false')))
except DiskFileDeviceUnavailable:
return HTTPInsufficientStorage(drive=device, request=request)
try:

View File

@ -5774,14 +5774,18 @@ class TestObjectController(unittest.TestCase):
self.assertEqual(resp.headers['X-Backend-Timestamp'],
utils.Timestamp(put_timestamp))
# ...unless X-Backend-Replication is sent
req = Request.blank(
'/sda1/p/a/c/o',
environ={'REQUEST_METHOD': 'GET'},
headers={'X-Timestamp': normalize_timestamp(now + 2),
'X-Backend-Replication': 'True'})
resp = req.get_response(self.object_controller)
self.assertEqual(resp.status_int, 200)
self.assertEqual('TEST', resp.body)
expected = {
'GET': 'TEST',
'HEAD': '',
}
for meth, expected_body in expected.items():
req = Request.blank(
'/sda1/p/a/c/o', method=meth,
headers={'X-Timestamp': normalize_timestamp(now + 2),
'X-Backend-Replication': 'True'})
resp = req.get_response(self.object_controller)
self.assertEqual(resp.status_int, 200)
self.assertEqual(expected_body, resp.body)
def test_HEAD_but_expired(self):
test_time = time() + 10000