Created
December 26, 2017 05:33
-
-
Save zaitcev/87b66fda723c1ad2a4cd03fd90cb98bc to your computer and use it in GitHub Desktop.
Alternative https://review.openstack.org/504341
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
commit dd727d8c69f60c86a68f5c48f98f196be0bdf4ac | |
Author: Tim Burke <tim.burke@gmail.com> | |
Date: Fri Sep 15 06:15:40 2017 +0000 | |
Differentiate between a drive that's not mounted vs. not a dir more | |
Change-Id: Ife0d34f9482adb4524d1ab1fe6c335c6b287c2fd | |
diff --git a/swift/account/reaper.py b/swift/account/reaper.py | |
index 0fe8adba2..dc7cc63ad 100644 | |
--- a/swift/account/reaper.py | |
+++ b/swift/account/reaper.py | |
@@ -28,7 +28,7 @@ import six | |
import swift.common.db | |
from swift.account.backend import AccountBroker, DATADIR | |
-from swift.common.constraints import check_drive | |
+from swift.common.constraints import check_drive, check_drive_msg | |
from swift.common.direct_client import direct_delete_container, \ | |
direct_delete_object, direct_get_container | |
from swift.common.exceptions import ClientException | |
@@ -134,10 +134,11 @@ class AccountReaper(Daemon): | |
begin = time() | |
try: | |
for device in os.listdir(self.devices): | |
- if not check_drive(self.devices, device, self.mount_check): | |
+ c = check_drive(self.devices, device, self.mount_check) | |
+ if not c[0]: | |
self.logger.increment('errors') | |
self.logger.debug( | |
- _('Skipping %s as it is not mounted'), device) | |
+ _('Skipping, %s'), check_drive_msg(device, c[1])) | |
continue | |
self.reap_device(device) | |
except (Exception, Timeout): | |
diff --git a/swift/account/server.py b/swift/account/server.py | |
index 0fe264723..cfa187375 100644 | |
--- a/swift/account/server.py | |
+++ b/swift/account/server.py | |
@@ -88,7 +88,7 @@ class AccountController(BaseStorageServer): | |
def DELETE(self, req): | |
"""Handle HTTP DELETE request.""" | |
drive, part, account = split_and_validate_path(req, 3) | |
- if not check_drive(self.root, drive, self.mount_check): | |
+ if not check_drive(self.root, drive, self.mount_check)[0]: | |
return HTTPInsufficientStorage(drive=drive, request=req) | |
req_timestamp = valid_timestamp(req) | |
broker = self._get_account_broker(drive, part, account) | |
@@ -102,7 +102,7 @@ class AccountController(BaseStorageServer): | |
def PUT(self, req): | |
"""Handle HTTP PUT request.""" | |
drive, part, account, container = split_and_validate_path(req, 3, 4) | |
- if not check_drive(self.root, drive, self.mount_check): | |
+ if not check_drive(self.root, drive, self.mount_check)[0]: | |
return HTTPInsufficientStorage(drive=drive, request=req) | |
if container: # put account container | |
if 'x-timestamp' not in req.headers: | |
@@ -169,7 +169,7 @@ class AccountController(BaseStorageServer): | |
"""Handle HTTP HEAD request.""" | |
drive, part, account = split_and_validate_path(req, 3) | |
out_content_type = listing_formats.get_listing_content_type(req) | |
- if not check_drive(self.root, drive, self.mount_check): | |
+ if not check_drive(self.root, drive, self.mount_check)[0]: | |
return HTTPInsufficientStorage(drive=drive, request=req) | |
broker = self._get_account_broker(drive, part, account, | |
pending_timeout=0.1, | |
@@ -204,7 +204,7 @@ class AccountController(BaseStorageServer): | |
end_marker = get_param(req, 'end_marker') | |
out_content_type = listing_formats.get_listing_content_type(req) | |
- if not check_drive(self.root, drive, self.mount_check): | |
+ if not check_drive(self.root, drive, self.mount_check)[0]: | |
return HTTPInsufficientStorage(drive=drive, request=req) | |
broker = self._get_account_broker(drive, part, account, | |
pending_timeout=0.1, | |
@@ -225,7 +225,7 @@ class AccountController(BaseStorageServer): | |
""" | |
post_args = split_and_validate_path(req, 3) | |
drive, partition, hash = post_args | |
- if not check_drive(self.root, drive, self.mount_check): | |
+ if not check_drive(self.root, drive, self.mount_check)[0]: | |
return HTTPInsufficientStorage(drive=drive, request=req) | |
try: | |
args = json.load(req.environ['wsgi.input']) | |
@@ -241,7 +241,7 @@ class AccountController(BaseStorageServer): | |
"""Handle HTTP POST request.""" | |
drive, part, account = split_and_validate_path(req, 3) | |
req_timestamp = valid_timestamp(req) | |
- if not check_drive(self.root, drive, self.mount_check): | |
+ if not check_drive(self.root, drive, self.mount_check)[0]: | |
return HTTPInsufficientStorage(drive=drive, request=req) | |
broker = self._get_account_broker(drive, part, account) | |
if broker.is_deleted(): | |
diff --git a/swift/common/constraints.py b/swift/common/constraints.py | |
index bb8fefcd8..2ed7e6f41 100644 | |
--- a/swift/common/constraints.py | |
+++ b/swift/common/constraints.py | |
@@ -17,6 +17,7 @@ import functools | |
import os | |
from os.path import isdir # tighter scoped import for mocking | |
import time | |
+from swift import gettext_ as _ | |
import six | |
from six.moves.configparser import ConfigParser, NoSectionError, NoOptionError | |
@@ -232,7 +233,7 @@ def check_dir(root, drive): | |
:param drive: drive name to be checked | |
:returns: full path to the device, or None if drive fails to validate | |
""" | |
- return check_drive(root, drive, False) | |
+ return check_drive(root, drive, False)[0] | |
def check_mount(root, drive): | |
@@ -246,7 +247,7 @@ def check_mount(root, drive): | |
:param drive: drive name to be checked | |
:returns: full path to the device, or None if drive fails to validate | |
""" | |
- return check_drive(root, drive, True) | |
+ return check_drive(root, drive, True)[0] | |
def check_drive(root, drive, mount_check): | |
@@ -257,18 +258,38 @@ def check_drive(root, drive, mount_check): | |
:param drive: drive name to be checked | |
:param mount_check: additionally require path is mounted | |
- :returns: full path to the device, or None if drive fails to validate | |
+ :returns: Tuple ( | |
+ full path to the device, or None if drive fails to validate, | |
+ error code if fails to validate (see check_drive_msg)) | |
""" | |
if not (urllib.parse.quote_plus(drive) == drive): | |
- return None | |
+ return None, 0 | |
path = os.path.join(root, drive) | |
if mount_check: | |
if utils.ismount(path): | |
- return path | |
+ return path, None | |
+ return None, 1 | |
else: | |
if isdir(path): | |
- return path | |
- return None | |
+ return path, None | |
+ return None, 2 | |
+ | |
+ | |
+def check_drive_msg(drive, code): | |
+ """ | |
+ Generate a message for a failure of check_drive() | |
+ | |
+ :param drive: The device name to include into the message | |
+ :param code: Error code returned by check_drive() | |
+ :returns: A formatted message | |
+ """ | |
+ if code == 0: | |
+ return _("%s contains special characters") % drive | |
+ if code == 1: | |
+ return _("%s is not mounted") % drive | |
+ if code == 2: | |
+ return _("%s is not a directory") % drive | |
+ return _("%s failed its check for unknown reason") % drive | |
def check_float(string): | |
diff --git a/swift/common/db_replicator.py b/swift/common/db_replicator.py | |
index 61713eedf..69783e1e8 100644 | |
--- a/swift/common/db_replicator.py | |
+++ b/swift/common/db_replicator.py | |
@@ -28,7 +28,7 @@ from eventlet import GreenPool, sleep, Timeout | |
from eventlet.green import subprocess | |
import swift.common.db | |
-from swift.common.constraints import check_drive | |
+from swift.common.constraints import check_drive, check_drive_msg | |
from swift.common.direct_client import quote | |
from swift.common.utils import get_logger, whataremyips, storage_directory, \ | |
renamer, mkdirs, lock_parent_directory, config_true_value, \ | |
@@ -637,14 +637,15 @@ class Replicator(Daemon): | |
node['replication_ip'], | |
node['replication_port']): | |
found_local = True | |
- if not check_drive(self.root, node['device'], | |
- self.mount_check): | |
+ c = check_drive(self.root, node['device'], self.mount_check) | |
+ if not c[0]: | |
self._add_failure_stats( | |
[(failure_dev['replication_ip'], | |
failure_dev['device']) | |
for failure_dev in self.ring.devs if failure_dev]) | |
self.logger.warning( | |
- _('Skipping %(device)s as it is not mounted') % node) | |
+ _('Skipping, %s'), | |
+ check_drive_msg(node['device'], c[1])) | |
continue | |
unlink_older_than( | |
os.path.join(self.root, node['device'], 'tmp'), | |
@@ -697,7 +698,7 @@ class ReplicatorRpc(object): | |
return HTTPBadRequest(body='Invalid object type') | |
op = args.pop(0) | |
drive, partition, hsh = replicate_args | |
- if not check_drive(self.root, drive, self.mount_check): | |
+ if not check_drive(self.root, drive, self.mount_check)[0]: | |
return Response(status='507 %s is not mounted' % drive) | |
db_file = os.path.join(self.root, drive, | |
storage_directory(self.datadir, partition, hsh), | |
diff --git a/swift/container/server.py b/swift/container/server.py | |
index 974a36734..f2d8cb906 100644 | |
--- a/swift/container/server.py | |
+++ b/swift/container/server.py | |
@@ -268,7 +268,7 @@ class ContainerController(BaseStorageServer): | |
drive, part, account, container, obj = split_and_validate_path( | |
req, 4, 5, True) | |
req_timestamp = valid_timestamp(req) | |
- if not check_drive(self.root, drive, self.mount_check): | |
+ if not check_drive(self.root, drive, self.mount_check)[0]: | |
return HTTPInsufficientStorage(drive=drive, request=req) | |
# policy index is only relevant for delete_obj (and transitively for | |
# auto create accounts) | |
@@ -356,7 +356,7 @@ class ContainerController(BaseStorageServer): | |
self.realms_conf) | |
if err: | |
return HTTPBadRequest(err) | |
- if not check_drive(self.root, drive, self.mount_check): | |
+ if not check_drive(self.root, drive, self.mount_check)[0]: | |
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) | |
@@ -424,7 +424,7 @@ class ContainerController(BaseStorageServer): | |
drive, part, account, container, obj = split_and_validate_path( | |
req, 4, 5, True) | |
out_content_type = listing_formats.get_listing_content_type(req) | |
- if not check_drive(self.root, drive, self.mount_check): | |
+ if not check_drive(self.root, drive, self.mount_check)[0]: | |
return HTTPInsufficientStorage(drive=drive, request=req) | |
broker = self._get_container_broker(drive, part, account, container, | |
pending_timeout=0.1, | |
@@ -488,7 +488,7 @@ class ContainerController(BaseStorageServer): | |
body='Maximum limit is %d' | |
% constraints.CONTAINER_LISTING_LIMIT) | |
out_content_type = listing_formats.get_listing_content_type(req) | |
- if not check_drive(self.root, drive, self.mount_check): | |
+ if not check_drive(self.root, drive, self.mount_check)[0]: | |
return HTTPInsufficientStorage(drive=drive, request=req) | |
broker = self._get_container_broker(drive, part, account, container, | |
pending_timeout=0.1, | |
@@ -534,7 +534,7 @@ class ContainerController(BaseStorageServer): | |
""" | |
post_args = split_and_validate_path(req, 3) | |
drive, partition, hash = post_args | |
- if not check_drive(self.root, drive, self.mount_check): | |
+ if not check_drive(self.root, drive, self.mount_check)[0]: | |
return HTTPInsufficientStorage(drive=drive, request=req) | |
try: | |
args = json.load(req.environ['wsgi.input']) | |
@@ -556,7 +556,7 @@ class ContainerController(BaseStorageServer): | |
self.realms_conf) | |
if err: | |
return HTTPBadRequest(err) | |
- if not check_drive(self.root, drive, self.mount_check): | |
+ if not check_drive(self.root, drive, self.mount_check)[0]: | |
return HTTPInsufficientStorage(drive=drive, request=req) | |
broker = self._get_container_broker(drive, part, account, container) | |
if broker.is_deleted(): | |
diff --git a/swift/container/updater.py b/swift/container/updater.py | |
index 5b199ae99..b795b565f 100644 | |
--- a/swift/container/updater.py | |
+++ b/swift/container/updater.py | |
@@ -26,7 +26,7 @@ from tempfile import mkstemp | |
from eventlet import spawn, Timeout | |
import swift.common.db | |
-from swift.common.constraints import check_drive | |
+from swift.common.constraints import check_drive, check_drive_msg | |
from swift.container.backend import ContainerBroker, DATADIR | |
from swift.common.bufferedhttp import http_connect | |
from swift.common.exceptions import ConnectionTimeout | |
@@ -101,11 +101,11 @@ class ContainerUpdater(Daemon): | |
""" | |
paths = [] | |
for device in self._listdir(self.devices): | |
- dev_path = check_drive(self.devices, device, self.mount_check) | |
- if not dev_path: | |
- self.logger.warning(_('%s is not mounted'), device) | |
+ c = check_drive(self.devices, device, self.mount_check) | |
+ if not c[0]: | |
+ self.logger.warning(check_drive_msg(device, c[1])) | |
continue | |
- con_path = os.path.join(dev_path, DATADIR) | |
+ con_path = os.path.join(c[0], DATADIR) | |
if not os.path.exists(con_path): | |
continue | |
for partition in self._listdir(con_path): | |
diff --git a/swift/obj/diskfile.py b/swift/obj/diskfile.py | |
index bd88b04ae..e6dac7e0d 100644 | |
--- a/swift/obj/diskfile.py | |
+++ b/swift/obj/diskfile.py | |
@@ -57,7 +57,7 @@ from pyeclib.ec_iface import ECDriverError, ECInvalidFragmentMetadata, \ | |
ECBadFragmentChecksum, ECInvalidParameter | |
from swift import gettext_ as _ | |
-from swift.common.constraints import check_drive | |
+from swift.common.constraints import check_drive, check_drive_msg | |
from swift.common.request_helpers import is_sys_meta | |
from swift.common.utils import mkdirs, Timestamp, \ | |
storage_directory, hash_path, renamer, fallocate, fsync, fdatasync, \ | |
@@ -429,11 +429,10 @@ def object_audit_location_generator(devices, mount_check=True, logger=None, | |
shuffle(device_dirs) | |
for device in device_dirs: | |
- if not check_drive(devices, device, mount_check): | |
+ c = check_drive(devices, device, mount_check) | |
+ if not c[0]: | |
if logger: | |
- logger.debug( | |
- 'Skipping %s as it is not %s', device, | |
- 'mounted' if mount_check else 'a dir') | |
+ logger.debug(_('Skipping, %s'), check_drive_msg(device, c[1])) | |
continue | |
# loop through object dirs for all policies | |
device_dir = os.path.join(devices, device) | |
@@ -1213,11 +1212,8 @@ class BaseDiskFileManager(object): | |
# explicitly forbidden from syscall, just return path | |
return join(self.devices, device) | |
# we'll do some kind of check if not explicitly forbidden | |
- if mount_check or self.mount_check: | |
- mount_check = True | |
- else: | |
- mount_check = False | |
- return check_drive(self.devices, device, mount_check) | |
+ return check_drive(self.devices, device, | |
+ mount_check or self.mount_check)[0] | |
@contextmanager | |
def replication_lock(self, device): | |
diff --git a/swift/obj/replicator.py b/swift/obj/replicator.py | |
index 56abbf848..afcfabd24 100644 | |
--- a/swift/obj/replicator.py | |
+++ b/swift/obj/replicator.py | |
@@ -29,7 +29,7 @@ from eventlet import GreenPool, tpool, Timeout, sleep | |
from eventlet.green import subprocess | |
from eventlet.support.greenlets import GreenletExit | |
-from swift.common.constraints import check_drive | |
+from swift.common.constraints import check_drive, check_drive_msg | |
from swift.common.ring.utils import is_local_device | |
from swift.common.utils import whataremyips, unlink_older_than, \ | |
compute_eta, get_logger, dump_recon_cache, \ | |
@@ -586,16 +586,16 @@ class ObjectReplicator(Daemon): | |
and (override_devices is None | |
or dev['device'] in override_devices))]: | |
found_local = True | |
- dev_path = check_drive(self.devices_dir, local_dev['device'], | |
- self.mount_check) | |
+ c = check_drive(self.devices_dir, local_dev['device'], | |
+ self.mount_check) | |
+ dev_path = c[0] | |
if not dev_path: | |
self._add_failure_stats( | |
[(failure_dev['replication_ip'], | |
failure_dev['device']) | |
for failure_dev in policy.object_ring.devs | |
if failure_dev]) | |
- self.logger.warning( | |
- _('%s is not mounted'), local_dev['device']) | |
+ self.logger.warning(check_drive_msg(local_dev['device'], c[1])) | |
continue | |
obj_path = join(dev_path, data_dir) | |
tmp_path = join(dev_path, get_tmp_dir(policy)) | |
@@ -730,13 +730,14 @@ class ObjectReplicator(Daemon): | |
if override_partitions and \ | |
job['partition'] not in override_partitions: | |
continue | |
- dev_path = check_drive(self.devices_dir, job['device'], | |
- self.mount_check) | |
+ c = check_drive(self.devices_dir, job['device'], | |
+ self.mount_check) | |
+ dev_path = c[0] | |
if not dev_path: | |
self._add_failure_stats([(failure_dev['replication_ip'], | |
failure_dev['device']) | |
for failure_dev in job['nodes']]) | |
- self.logger.warning(_('%s is not mounted'), job['device']) | |
+ self.logger.warning(check_drive_msg(job['device'], c[1])) | |
continue | |
if self.handoffs_first and not job['delete']: | |
# in handoffs first mode, we won't process primary | |
diff --git a/swift/obj/updater.py b/swift/obj/updater.py | |
index 0726d42cc..b86ceffcd 100644 | |
--- a/swift/obj/updater.py | |
+++ b/swift/obj/updater.py | |
@@ -24,7 +24,7 @@ from random import random | |
from eventlet import spawn, Timeout | |
from swift.common.bufferedhttp import http_connect | |
-from swift.common.constraints import check_drive | |
+from swift.common.constraints import check_drive, check_drive_msg | |
from swift.common.exceptions import ConnectionTimeout | |
from swift.common.ring import Ring | |
from swift.common.utils import get_logger, renamer, write_pickle, \ | |
@@ -94,10 +94,11 @@ class ObjectUpdater(Daemon): | |
# read from container ring to ensure it's fresh | |
self.get_container_ring().get_nodes('') | |
for device in self._listdir(self.devices): | |
- if not check_drive(self.devices, device, self.mount_check): | |
+ c = check_drive(self.devices, device, self.mount_check) | |
+ if not c[0]: | |
self.logger.increment('errors') | |
self.logger.warning( | |
- _('Skipping %s as it is not mounted'), device) | |
+ _('Skipping, %s'), check_drive_msg(device, c[1])) | |
continue | |
while len(pids) >= self.concurrency: | |
pids.remove(os.wait()[0]) | |
@@ -136,10 +137,11 @@ class ObjectUpdater(Daemon): | |
self.successes = 0 | |
self.failures = 0 | |
for device in self._listdir(self.devices): | |
- if not check_drive(self.devices, device, self.mount_check): | |
+ c = check_drive(self.devices, device, self.mount_check) | |
+ if not c[0]: | |
self.logger.increment('errors') | |
self.logger.warning( | |
- _('Skipping %s as it is not mounted'), device) | |
+ _('Skipping, %s'), check_drive_msg(device, c[1])) | |
continue | |
self.object_sweep(os.path.join(self.devices, device)) | |
elapsed = time.time() - begin | |
diff --git a/test/unit/common/test_constraints.py b/test/unit/common/test_constraints.py | |
index c975a135c..1272ef8fd 100644 | |
--- a/test/unit/common/test_constraints.py | |
+++ b/test/unit/common/test_constraints.py | |
@@ -377,8 +377,10 @@ class TestConstraints(unittest.TestCase): | |
with mock_check_drive() as mocks: | |
self.assertIsNone(constraints.check_dir(root, 'foo?bar')) | |
self.assertIsNone(constraints.check_mount(root, 'foo bar')) | |
- self.assertIsNone(constraints.check_drive(root, 'foo/bar', True)) | |
- self.assertIsNone(constraints.check_drive(root, 'foo%bar', False)) | |
+ self.assertEqual( | |
+ constraints.check_drive(root, 'foo/bar', True), (None, 0)) | |
+ self.assertEqual( | |
+ constraints.check_drive(root, 'foo%bar', False), (None, 0)) | |
self.assertEqual([], mocks['isdir'].call_args_list) | |
self.assertEqual([], mocks['ismount'].call_args_list) | |
@@ -387,14 +389,14 @@ class TestConstraints(unittest.TestCase): | |
path = 'sdb1' | |
with mock_check_drive(ismount=True) as mocks: | |
self.assertIsNone(constraints.check_dir(root, path)) | |
- self.assertIsNone(constraints.check_drive(root, path, False)) | |
+ self.assertIsNone(constraints.check_drive(root, path, False)[0]) | |
self.assertEqual([mock.call('/srv/sdb1'), mock.call('/srv/sdb1')], | |
mocks['isdir'].call_args_list) | |
self.assertEqual([], mocks['ismount'].call_args_list) | |
with mock_check_drive(ismount=True) as mocks: | |
self.assertEqual('/srv/sdb1', constraints.check_mount(root, path)) | |
self.assertEqual('/srv/sdb1', constraints.check_drive( | |
- root, path, True)) | |
+ root, path, True)[0]) | |
self.assertEqual([], mocks['isdir'].call_args_list) | |
self.assertEqual([mock.call('/srv/sdb1'), mock.call('/srv/sdb1')], | |
mocks['ismount'].call_args_list) | |
@@ -405,13 +407,13 @@ class TestConstraints(unittest.TestCase): | |
with mock_check_drive(isdir=True) as mocks: | |
self.assertEqual('/srv/sdb2', constraints.check_dir(root, path)) | |
self.assertEqual('/srv/sdb2', constraints.check_drive( | |
- root, path, False)) | |
+ root, path, False)[0]) | |
self.assertEqual([mock.call('/srv/sdb2'), mock.call('/srv/sdb2')], | |
mocks['isdir'].call_args_list) | |
self.assertEqual([], mocks['ismount'].call_args_list) | |
with mock_check_drive(isdir=True) as mocks: | |
self.assertIsNone(constraints.check_mount(root, path)) | |
- self.assertIsNone(constraints.check_drive(root, path, True)) | |
+ self.assertIsNone(constraints.check_drive(root, path, True)[0]) | |
self.assertEqual([], mocks['isdir'].call_args_list) | |
self.assertEqual([mock.call('/srv/sdb2'), mock.call('/srv/sdb2')], | |
mocks['ismount'].call_args_list) | |
diff --git a/test/unit/common/test_db_replicator.py b/test/unit/common/test_db_replicator.py | |
index a1e818cef..8ffb85a15 100644 | |
--- a/test/unit/common/test_db_replicator.py | |
+++ b/test/unit/common/test_db_replicator.py | |
@@ -520,7 +520,7 @@ class TestDBReplicator(unittest.TestCase): | |
self.assertEqual(root, replicator.root) | |
self.assertEqual(device, replicator.ring.devs[0]['device']) | |
self.assertEqual(mount_check, True) | |
- return None | |
+ return None, 1 | |
self._patch(patch.object, db_replicator, 'check_drive', | |
mock_check_drive) | |
@@ -528,8 +528,8 @@ class TestDBReplicator(unittest.TestCase): | |
self.assertEqual( | |
replicator.logger.log_dict['warning'], | |
- [(('Skipping %(device)s as it is not mounted' % | |
- replicator.ring.devs[0],), {})]) | |
+ [((('Skipping, %s'), ('%s is not %s' % | |
+ (replicator.ring.devs[0]['device'], 'mounted'),),), {})]) | |
def test_run_once_node_is_mounted(self): | |
db_replicator.ring = FakeRingWithSingleNode() | |
diff --git a/test/unit/obj/test_diskfile.py b/test/unit/obj/test_diskfile.py | |
index 73acc4663..198d6e47d 100644 | |
--- a/test/unit/obj/test_diskfile.py | |
+++ b/test/unit/obj/test_diskfile.py | |
@@ -486,7 +486,7 @@ class TestObjectAuditLocationGenerator(unittest.TestCase): | |
devices=tmpdir, mount_check=True, logger=logger)] | |
debug_lines = logger.get_lines_for_level('debug') | |
self.assertEqual([ | |
- 'Skipping sdq as it is not mounted', | |
+ 'Skipping, sdq is not mounted', | |
], debug_lines) | |
def test_skipping_files(self): | |
@@ -517,7 +517,7 @@ class TestObjectAuditLocationGenerator(unittest.TestCase): | |
devices=tmpdir, mount_check=False, logger=logger)] | |
debug_lines = logger.get_lines_for_level('debug') | |
self.assertEqual([ | |
- 'Skipping garbage as it is not a dir', | |
+ 'Skipping, garbage is not a directory', | |
], debug_lines) | |
logger.clear() | |
with mock_check_drive(isdir=True): | |
@@ -540,7 +540,7 @@ class TestObjectAuditLocationGenerator(unittest.TestCase): | |
devices=tmpdir, mount_check=True, logger=logger)] | |
debug_lines = logger.get_lines_for_level('debug') | |
self.assertEqual([ | |
- 'Skipping garbage as it is not mounted', | |
+ 'Skipping, garbage is not mounted', | |
], debug_lines) | |
def test_only_catch_expected_errors(self): | |
diff --git a/test/unit/obj/test_reconstructor.py b/test/unit/obj/test_reconstructor.py | |
index 176afdfca..37b464290 100644 | |
--- a/test/unit/obj/test_reconstructor.py | |
+++ b/test/unit/obj/test_reconstructor.py | |
@@ -2767,8 +2767,8 @@ class TestObjectReconstructor(BaseTestObjectReconstructor): | |
if (not mount_check) and os.path.isdir(path): | |
# while mount_check is false, the test still creates the dirs | |
paths.append(path) | |
- return path | |
- return None | |
+ return (path, None) | |
+ return None, 1 | |
with mock.patch('swift.obj.reconstructor.whataremyips', | |
return_value=[self.ip]), \ | |
@@ -2806,9 +2806,9 @@ class TestObjectReconstructor(BaseTestObjectReconstructor): | |
def fake_check_drive(devices, device, mount_check): | |
self.assertTrue(mount_check) | |
if device == 'sda': | |
- return os.path.join(devices, device) | |
+ return os.path.join(devices, device), None | |
else: | |
- return False | |
+ return None, 1 | |
with mock.patch('swift.obj.reconstructor.whataremyips', | |
return_value=[self.ip]), \ | |
diff --git a/test/unit/obj/test_updater.py b/test/unit/obj/test_updater.py | |
index 30012f1a7..8b25fc538 100644 | |
--- a/test/unit/obj/test_updater.py | |
+++ b/test/unit/obj/test_updater.py | |
@@ -250,7 +250,7 @@ class TestObjectUpdater(unittest.TestCase): | |
@mock.patch.object(object_updater, 'check_drive') | |
def test_run_once_with_disk_unmounted(self, mock_check_drive): | |
- mock_check_drive.return_value = False | |
+ mock_check_drive.return_value = (None, 0) | |
ou = object_updater.ObjectUpdater({ | |
'devices': self.devices_dir, | |
'mount_check': 'false', | |
@@ -290,7 +290,7 @@ class TestObjectUpdater(unittest.TestCase): | |
@mock.patch.object(object_updater, 'check_drive') | |
def test_run_once(self, mock_check_drive): | |
- mock_check_drive.return_value = True | |
+ mock_check_drive.return_value = (self.sda1, None) | |
ou = object_updater.ObjectUpdater({ | |
'devices': self.devices_dir, | |
'mount_check': 'false', |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment