summaryrefslogtreecommitdiffstats
path: root/gluster/swift/common/utils.py
diff options
context:
space:
mode:
authorPrashanth Pai <ppai@redhat.com>2013-10-30 16:13:50 +0530
committerLuis Pabon <lpabon@redhat.com>2013-11-14 11:02:19 -0800
commita43de0dc5b0c6781c86a8da05d3ebe31f992510e (patch)
tree400c4cf3dc71ef14a462ba9160518405be5c3eb6 /gluster/swift/common/utils.py
parent7aa628033d3ac224876d5c0f84d8d546a0fb1507 (diff)
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 <ppai@redhat.com> Reviewed-on: http://review.gluster.org/6199 Reviewed-by: Luis Pabon <lpabon@redhat.com> Tested-by: Luis Pabon <lpabon@redhat.com>
Diffstat (limited to 'gluster/swift/common/utils.py')
-rw-r--r--gluster/swift/common/utils.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/gluster/swift/common/utils.py b/gluster/swift/common/utils.py
index 595a965..ea3a07f 100644
--- a/gluster/swift/common/utils.py
+++ b/gluster/swift/common/utils.py
@@ -24,8 +24,10 @@ from eventlet import sleep
import cPickle as pickle
from swift.common.utils import normalize_timestamp
from gluster.swift.common.exceptions import GlusterFileSystemIOError
+from swift.common.exceptions import DiskFileNoSpace
from gluster.swift.common.fs_utils import do_rename, do_fsync, os_path, \
- do_stat, do_fstat, do_listdir, do_walk, do_rmdir
+ do_stat, do_fstat, do_listdir, do_walk, do_rmdir, do_log_rl, \
+ get_filename_from_fd
from gluster.swift.common import Glusterfs
X_CONTENT_TYPE = 'Content-Type'
@@ -124,9 +126,19 @@ def write_metadata(path_or_fd, metadata):
'%s%s' % (METADATA_KEY, key or ''),
metastr[:MAX_XATTR_SIZE])
except IOError as err:
- raise GlusterFileSystemIOError(
- err.errno,
- 'xattr.setxattr("%s", %s, metastr)' % (path_or_fd, key))
+ if err.errno in (errno.ENOSPC, errno.EDQUOT):
+ if isinstance(path_or_fd, int):
+ filename = get_filename_from_fd(path_or_fd)
+ do_log_rl("write_metadata(%d, metadata) failed: %s : %s",
+ path_or_fd, err, filename)
+ else:
+ do_log_rl("write_metadata(%s, metadata) failed: %s",
+ path_or_fd, err)
+ raise DiskFileNoSpace()
+ else:
+ raise GlusterFileSystemIOError(
+ err.errno,
+ 'xattr.setxattr("%s", %s, metastr)' % (path_or_fd, key))
metastr = metastr[MAX_XATTR_SIZE:]
key += 1