Logging a policy index when container PUT request conflicts

This is a continuing work of patch afdbf73. This patch enables
proxy-server to log a policy index when container PUT request
conflicts with existing container's policy index.

Change-Id: I6d40044c510632a0f61b817a9af2f6c13a721d39
Implements: blueprint logging-policy-number
This commit is contained in:
Daisuke Morita 2015-02-12 05:12:56 +09:00
parent 843ce7e301
commit f5d509471b
2 changed files with 6 additions and 1 deletions

View File

@ -308,7 +308,9 @@ class ContainerController(BaseStorageServer):
elif requested_policy_index is not None:
# validate requested policy with existing container
if requested_policy_index != broker.storage_policy_index:
raise HTTPConflict(request=req)
raise HTTPConflict(request=req,
headers={'x-backend-storage-policy-index':
broker.storage_policy_index})
broker.update_put_timestamp(timestamp)
if broker.is_deleted():
raise HTTPConflict(request=req)

View File

@ -476,6 +476,9 @@ class TestContainerController(unittest.TestCase):
})
resp = req.get_response(self.controller)
self.assertEquals(resp.status_int, 409)
self.assertEquals(
resp.headers.get('X-Backend-Storage-Policy-Index'),
str(policy.idx))
# and make sure there is no change!
req = Request.blank('/sda1/p/a/c')