Fixed bug where expirer would get confused by...

Fixed bug where expirer would get confused by odd deletion times.
Since this has already rolled out, I just capped things at ten 9s, or
Sat Nov 20 17:46:39 2286. I can't wait for the Y2286 world panic. :/

Change-Id: Iba10963faa344a418a1fa573d5c85f4ff864b574
This commit is contained in:
gholt 2012-08-06 20:53:24 +00:00
parent b06bfa69a6
commit 61932d8506
2 changed files with 39 additions and 0 deletions

View File

@ -471,6 +471,10 @@ class ObjectController(object):
:param headers_in: dictionary of headers from the original request
:param objdevice: device name that the object is in
"""
# Quick cap that will work from now until Sat Nov 20 17:46:39 2286
# At that time, Swift will be so popular and pervasive I will have
# created income for thousands of future programmers.
delete_at = max(min(delete_at, 9999999999), 0)
host = partition = contdevice = None
headers_out = {'x-timestamp': headers_in['x-timestamp'],
'x-trans-id': headers_in.get('x-trans-id', '-')}

View File

@ -1641,6 +1641,41 @@ class TestObjectController(unittest.TestCase):
'x-trans-id': '-'},
'sda1'])
def test_delete_at_negative(self):
# Test negative is reset to 0
given_args = []
def fake_async_update(*args):
given_args.extend(args)
self.object_controller.async_update = fake_async_update
self.object_controller.delete_at_update(
'PUT', -2, 'a', 'c', 'o', {'x-timestamp': '1'}, 'sda1')
self.assertEquals(given_args, [
'PUT', '.expiring_objects', '0', '0-a/c/o', None, None, None,
{'x-size': '0', 'x-etag': 'd41d8cd98f00b204e9800998ecf8427e',
'x-content-type': 'text/plain', 'x-timestamp': '1',
'x-trans-id': '-'},
'sda1'])
def test_delete_at_cap(self):
# Test past cap is reset to cap
given_args = []
def fake_async_update(*args):
given_args.extend(args)
self.object_controller.async_update = fake_async_update
self.object_controller.delete_at_update(
'PUT', 12345678901, 'a', 'c', 'o', {'x-timestamp': '1'}, 'sda1')
self.assertEquals(given_args, [
'PUT', '.expiring_objects', '9999936000', '9999999999-a/c/o', None,
None, None,
{'x-size': '0', 'x-etag': 'd41d8cd98f00b204e9800998ecf8427e',
'x-content-type': 'text/plain', 'x-timestamp': '1',
'x-trans-id': '-'},
'sda1'])
def test_delete_at_update_put_with_info(self):
given_args = []