From 1a6b55714fddf7a1b526a31ee3f27589f01e98e5 Mon Sep 17 00:00:00 2001 From: Chetan Risbud Date: Tue, 4 Mar 2014 19:35:24 +0530 Subject: PUT of a Directory failed PUT of a directory fails with gluster-swift when there exists object of a same name. This is because the objects and directories are placed on the glusterfs. And hence the filesystem semantics are applicable there. Exceptions raised in such situation are needed to be handled and reported correctly back to proxy-server with HTTPConflict as a error code. Although swift still continues to choose 503 as the best respose in such cases. No tracebacks reported. Fix covers the case when there exists a directory and object of the same name is PUT. Code changes fixes both the failure cases mentioned in the bug. Examples of failing PUT requests: 1) curl -v -X PUT http://127.0.0.1:8080/v1/AUTH_test/c1/dir1/obj2/anotherobject -d'asdasdsadA' -- obj2 was already an object. 2)curl -v -H 'Content-Length: 0' -H 'Content-Type: application/directory' -X PUT http://127.0.0.1:8080/v1/AUTH_test/c1/obj1 -- obj1 was already and object Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1071021 Change-Id: Id3042d920e3f99e740d4042ef5907ac8c59e04db Signed-off-by: Chetan Risbud Reviewed-on: http://review.gluster.org/7181 Reviewed-by: Prashanth Pai Tested-by: Prashanth Pai --- test/unit/obj/test_diskfile.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/unit/obj/test_diskfile.py b/test/unit/obj/test_diskfile.py index a767261..64fa6e7 100644 --- a/test/unit/obj/test_diskfile.py +++ b/test/unit/obj/test_diskfile.py @@ -26,7 +26,8 @@ from eventlet import tpool from mock import Mock, patch from hashlib import md5 from copy import deepcopy - +from gluster.swift.common.exceptions import AlreadyExistsAsDir, \ + AlreadyExistsAsFile from swift.common.exceptions import DiskFileNotExist, DiskFileError, \ DiskFileNoSpace, DiskFileNotOpen from swift.common.utils import ThreadPool @@ -409,7 +410,7 @@ class TestDiskFile(unittest.TestCase): dc = gluster.swift.obj.diskfile.do_chown gluster.swift.obj.diskfile.do_chown = _mock_do_chown self.assertRaises( - DiskFileError, gdf._create_dir_object, the_dir) + AlreadyExistsAsFile, gdf._create_dir_object, the_dir) gluster.swift.obj.diskfile.do_chown = dc self.assertFalse(os.path.isdir(the_dir)) self.assertFalse(_mapit(the_dir) in _metadata) @@ -431,7 +432,7 @@ class TestDiskFile(unittest.TestCase): dc = gluster.swift.obj.diskfile.do_chown gluster.swift.obj.diskfile.do_chown = _mock_do_chown self.assertRaises( - DiskFileError, gdf._create_dir_object, the_dir) + AlreadyExistsAsFile, gdf._create_dir_object, the_dir) gluster.swift.obj.diskfile.do_chown = dc self.assertFalse(os.path.isdir(the_dir)) self.assertFalse(_mapit(the_dir) in _metadata) @@ -622,7 +623,7 @@ class TestDiskFile(unittest.TestCase): # directory. dw.write('12345\n') dw.put(newmd) - except DiskFileError: + except AlreadyExistsAsDir: pass else: self.fail("Expected to encounter" -- cgit