diff --git a/swift/account/server.py b/swift/account/server.py index 803b90cca8..81c4d9049f 100644 --- a/swift/account/server.py +++ b/swift/account/server.py @@ -142,14 +142,8 @@ class AccountController(object): @timing_stats() def HEAD(self, req): """Handle HTTP HEAD request.""" - # TODO(refactor): The account server used to provide a 'account and - # container existence check all-in-one' call by doing a HEAD with a - # container path. However, container existence is now checked with the - # container servers directly so this is no longer needed. We should - # refactor out the container existence check here and retest - # everything. try: - drive, part, account, container = req.split_path(3, 4) + drive, part, account = req.split_path(3) validate_device_partition(drive, part) except ValueError, err: return HTTPBadRequest(body=str(err), content_type='text/plain', @@ -157,9 +151,8 @@ class AccountController(object): if self.mount_check and not check_mount(self.root, drive): return HTTPInsufficientStorage(drive=drive, request=req) broker = self._get_account_broker(drive, part, account) - if not container: - broker.pending_timeout = 0.1 - broker.stale_reads_ok = True + broker.pending_timeout = 0.1 + broker.stale_reads_ok = True if broker.is_deleted(): return HTTPNotFound(request=req) info = broker.get_info() @@ -169,10 +162,6 @@ class AccountController(object): 'X-Account-Bytes-Used': info['bytes_used'], 'X-Timestamp': info['created_at'], 'X-PUT-Timestamp': info['put_timestamp']} - if container: - container_ts = broker.get_container_timestamp(container) - if container_ts is not None: - headers['X-Container-Timestamp'] = container_ts headers.update((key, value) for key, (value, timestamp) in broker.metadata.iteritems() if value != '') diff --git a/swift/common/db.py b/swift/common/db.py index c6137fe73e..1f70c89285 100644 --- a/swift/common/db.py +++ b/swift/common/db.py @@ -1407,28 +1407,6 @@ class AccountBroker(DatabaseBroker): DatabaseBroker._reclaim(self, conn, container_timestamp) conn.commit() - def get_container_timestamp(self, container_name): - """ - Get the put_timestamp of a container. - - :param container_name: container name - - :returns: put_timestamp of the container - """ - try: - self._commit_puts() - except LockTimeout: - if not self.stale_reads_ok: - raise - with self.get() as conn: - ret = conn.execute(''' - SELECT put_timestamp FROM container - WHERE name = ? AND deleted != 1''', - (container_name,)).fetchone() - if ret: - ret = ret[0] - return ret - def put_container(self, name, put_timestamp, delete_timestamp, object_count, bytes_used): """ diff --git a/test/unit/common/test_db.py b/test/unit/common/test_db.py index 257e53479c..ce9b1f4df7 100644 --- a/test/unit/common/test_db.py +++ b/test/unit/common/test_db.py @@ -1662,21 +1662,6 @@ class TestAccountBroker(unittest.TestCase): "SELECT count(*) FROM container " "WHERE deleted = 1").fetchone()[0], 1) - def test_get_container_timestamp(self): - """ Test swift.common.db.AccountBroker.get_container_timestamp """ - broker = AccountBroker(':memory:', account='a') - broker.initialize(normalize_timestamp('1')) - - # Create initial container - timestamp = normalize_timestamp(time()) - broker.put_container('container_name', timestamp, 0, 0, 0) - # test extant map - ts = broker.get_container_timestamp('container_name') - self.assertEquals(ts, timestamp) - # test missing map - ts = broker.get_container_timestamp('something else') - self.assertEquals(ts, None) - def test_put_container(self): """ Test swift.common.db.AccountBroker.put_container """ broker = AccountBroker(':memory:', account='a')