Created
March 31, 2017 21:02
-
-
Save clayg/411374f07801bf9d2cd70aee0bf75936 to your computer and use it in GitHub Desktop.
this is basically what the object server does already
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/swift/container/server.py b/swift/container/server.py | |
index 152603f..9f0f348 100644 | |
--- a/swift/container/server.py | |
+++ b/swift/container/server.py | |
@@ -35,7 +35,8 @@ from swift.common.utils import get_logger, hash_path, public, \ | |
Timestamp, storage_directory, validate_sync_to, \ | |
config_true_value, timing_stats, replication, \ | |
override_bytes_from_content_type, get_log_line | |
-from swift.common.constraints import check_mount, valid_timestamp, check_utf8 | |
+from swift.common.constraints import check_mount, valid_timestamp, \ | |
+ check_utf8, check_dir | |
from swift.common import constraints | |
from swift.common.bufferedhttp import http_connect | |
from swift.common.exceptions import ConnectionTimeout | |
@@ -256,6 +257,12 @@ class ContainerController(BaseStorageServer): | |
self.logger.exception('Failed to update sync_store %s during %s' % | |
(broker.db_file, method)) | |
+ def check_mount(self, drive): | |
+ if self.mount_check: | |
+ return check_mount(self.root, drive) | |
+ else: | |
+ return check_dir(self.root, drive) | |
+ | |
@public | |
@timing_stats() | |
def DELETE(self, req): | |
@@ -263,7 +270,7 @@ class ContainerController(BaseStorageServer): | |
drive, part, account, container, obj = split_and_validate_path( | |
req, 4, 5, True) | |
req_timestamp = valid_timestamp(req) | |
- if self.mount_check and not check_mount(self.root, drive): | |
+ if not self.check_mount(drive): | |
return HTTPInsufficientStorage(drive=drive, request=req) | |
# policy index is only relevant for delete_obj (and transitively for | |
# auto create accounts) | |
@@ -351,7 +358,7 @@ class ContainerController(BaseStorageServer): | |
self.realms_conf) | |
if err: | |
return HTTPBadRequest(err) | |
- if self.mount_check and not check_mount(self.root, drive): | |
+ if not self.check_mount(drive): | |
return HTTPInsufficientStorage(drive=drive, request=req) | |
requested_policy_index = self.get_and_validate_policy_index(req) | |
broker = self._get_container_broker(drive, part, account, container) | |
@@ -419,7 +426,7 @@ class ContainerController(BaseStorageServer): | |
drive, part, account, container, obj = split_and_validate_path( | |
req, 4, 5, True) | |
out_content_type = get_listing_content_type(req) | |
- if self.mount_check and not check_mount(self.root, drive): | |
+ if not self.check_mount(drive): | |
return HTTPInsufficientStorage(drive=drive, request=req) | |
broker = self._get_container_broker(drive, part, account, container, | |
pending_timeout=0.1, | |
@@ -483,7 +490,7 @@ class ContainerController(BaseStorageServer): | |
body='Maximum limit is %d' | |
% constraints.CONTAINER_LISTING_LIMIT) | |
out_content_type = get_listing_content_type(req) | |
- if self.mount_check and not check_mount(self.root, drive): | |
+ if not self.check_mount(drive): | |
return HTTPInsufficientStorage(drive=drive, request=req) | |
broker = self._get_container_broker(drive, part, account, container, | |
pending_timeout=0.1, | |
@@ -545,7 +552,7 @@ class ContainerController(BaseStorageServer): | |
""" | |
post_args = split_and_validate_path(req, 3) | |
drive, partition, hash = post_args | |
- if self.mount_check and not check_mount(self.root, drive): | |
+ if not self.check_mount(drive): | |
return HTTPInsufficientStorage(drive=drive, request=req) | |
try: | |
args = json.load(req.environ['wsgi.input']) | |
@@ -567,7 +574,7 @@ class ContainerController(BaseStorageServer): | |
self.realms_conf) | |
if err: | |
return HTTPBadRequest(err) | |
- if self.mount_check and not check_mount(self.root, drive): | |
+ if not self.check_mount(drive): | |
return HTTPInsufficientStorage(drive=drive, request=req) | |
broker = self._get_container_broker(drive, part, account, container) | |
if broker.is_deleted(): |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment