From a43de0dc5b0c6781c86a8da05d3ebe31f992510e Mon Sep 17 00:00:00 2001 From: Prashanth Pai Date: Wed, 30 Oct 2013 16:13:50 +0530 Subject: Improve logging and raising DiskFileNoSpace This commit only improves logging whenever ENOSPC (No space on disk) or EDQUOT (Quota limit exceeded) is returned by glusterfs Also, added methods to: - get filename from file descriptor - log with rate limit Caveat: Although raising DiskFileNoSpace results in object-server returning HTTPInsufficientStorage[507] correctly, the swift proxy-server invokes "best_response" method that returns [503] to the user. When write-behind translator is turned on in glusterfs, it may set errno to EIO instead of ENOSPC/EDQUOT. This is documented in BZ 986812 BUG: 985862, 985253, 1020724 Change-Id: Ib0c5e41c11a8cdccc2077f71c31d8a23229452bb Signed-off-by: Prashanth Pai Reviewed-on: http://review.gluster.org/6199 Reviewed-by: Luis Pabon Tested-by: Luis Pabon --- test/unit/common/test_utils.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test/unit/common/test_utils.py') diff --git a/test/unit/common/test_utils.py b/test/unit/common/test_utils.py index 72d62d0..563df91 100644 --- a/test/unit/common/test_utils.py +++ b/test/unit/common/test_utils.py @@ -29,6 +29,7 @@ from mock import patch from swift.common.utils import normalize_timestamp from gluster.swift.common import utils, Glusterfs from gluster.swift.common.exceptions import GlusterFileSystemOSError +from swift.common.exceptions import DiskFileNoSpace # # Somewhat hacky way of emulating the operation of xattr calls. They are made @@ -170,6 +171,28 @@ class TestUtils(unittest.TestCase): else: self.fail("Expected an IOError exception on write") + def test_write_metadata_space_err(self): + + def _mock_xattr_setattr(item, name, value): + raise IOError(errno.ENOSPC, os.strerror(errno.ENOSPC)) + + with patch('xattr.setxattr', _mock_xattr_setattr): + path = "/tmp/foo/w" + orig_d = {'bar': 'foo'} + try: + utils.write_metadata(path, orig_d) + except DiskFileNoSpace: + pass + else: + self.fail("Expected DiskFileNoSpace exception") + fd = 0 + try: + utils.write_metadata(fd, orig_d) + except DiskFileNoSpace: + pass + else: + self.fail("Expected DiskFileNoSpace exception") + def test_write_metadata_multiple(self): # At 64 KB an xattr key/value pair, this should generate three keys. path = "/tmp/foo/w" -- cgit