summaryrefslogtreecommitdiffstats
path: root/gluster
diff options
context:
space:
mode:
Diffstat (limited to 'gluster')
-rw-r--r--gluster/swift/common/DiskFile.py9
-rw-r--r--gluster/swift/common/exceptions.py4
-rw-r--r--gluster/swift/obj/server.py17
3 files changed, 26 insertions, 4 deletions
diff --git a/gluster/swift/common/DiskFile.py b/gluster/swift/common/DiskFile.py
index 4b6602e..d64726b 100644
--- a/gluster/swift/common/DiskFile.py
+++ b/gluster/swift/common/DiskFile.py
@@ -24,7 +24,9 @@ from eventlet import sleep
from contextlib import contextmanager
from swift.common.utils import TRUE_VALUES, fallocate
from swift.common.exceptions import DiskFileNotExist, DiskFileError
-from gluster.swift.common.exceptions import GlusterFileSystemOSError
+
+from gluster.swift.common.exceptions import GlusterFileSystemOSError, \
+ DiskFileNoSpace
from gluster.swift.common.fs_utils import do_fstat, do_open, do_close, \
do_unlink, do_chown, os_path, do_fsync, do_fchown, do_stat
from gluster.swift.common.utils import read_metadata, write_metadata, \
@@ -702,6 +704,11 @@ class Gluster_DiskFile(DiskFile):
fd = do_open(tmppath,
os.O_WRONLY | os.O_CREAT | os.O_EXCL | O_CLOEXEC)
except GlusterFileSystemOSError as gerr:
+ if gerr.errno == errno.ENOSPC:
+ # Raise DiskFileNoSpace to be handled by upper layers
+ excp = DiskFileNoSpace()
+ excp.drive = os.path.basename(self.device_path)
+ raise excp
if gerr.errno == errno.EEXIST:
# Retry with a different random number.
continue
diff --git a/gluster/swift/common/exceptions.py b/gluster/swift/common/exceptions.py
index 010ea24..ba2364e 100644
--- a/gluster/swift/common/exceptions.py
+++ b/gluster/swift/common/exceptions.py
@@ -44,3 +44,7 @@ class AlreadyExistsAsDir(GlusterfsException):
class AlreadyExistsAsFile(GlusterfsException):
pass
+
+
+class DiskFileNoSpace(GlusterfsException):
+ pass
diff --git a/gluster/swift/obj/server.py b/gluster/swift/obj/server.py
index e7b9ff3..b3747ab 100644
--- a/gluster/swift/obj/server.py
+++ b/gluster/swift/obj/server.py
@@ -17,11 +17,13 @@
# Simply importing this monkey patches the constraint handling to fit our
# needs
-import gluster.swift.common.constraints # noqa
-import gluster.swift.common.utils # noqa
-
from swift.obj import server
+import gluster.swift.common.utils # noqa
+import gluster.swift.common.constraints # noqa
+from swift.common.utils import public, timing_stats
from gluster.swift.common.DiskFile import Gluster_DiskFile
+from gluster.swift.common.exceptions import DiskFileNoSpace
+from swift.common.swob import HTTPInsufficientStorage
# Monkey patch the object server module to use Gluster's DiskFile definition
server.DiskFile = Gluster_DiskFile
@@ -54,6 +56,15 @@ class ObjectController(server.ObjectController):
"""
return
+ @public
+ @timing_stats()
+ def PUT(self, request):
+ try:
+ return server.ObjectController.PUT(self, request)
+ except DiskFileNoSpace as err:
+ drive = err.drive
+ return HTTPInsufficientStorage(drive=drive, request=request)
+
def app_factory(global_conf, **local_conf):
"""paste.deploy app factory for creating WSGI object server apps"""