Merge "trivial: Default value for EUCLEAN"
This commit is contained in:
commit
a427d2754f
@ -162,6 +162,8 @@ from swift.common.utils.ipaddrs import ( # noqa
|
||||
from swift.common.statsd_client import StatsdClient # noqa
|
||||
import logging
|
||||
|
||||
EUCLEAN = getattr(errno, 'EUCLEAN', 117) # otherwise not present on osx
|
||||
|
||||
# These are lazily pulled from libc elsewhere
|
||||
_sys_fallocate = None
|
||||
|
||||
|
@ -66,7 +66,7 @@ from swift.common.utils import mkdirs, Timestamp, \
|
||||
MD5_OF_EMPTY_STRING, link_fd_to_path, \
|
||||
O_TMPFILE, makedirs_count, replace_partition_in_path, remove_directory, \
|
||||
md5, is_file_older, non_negative_float, config_fallocate_value, \
|
||||
fs_has_free_space, CooperativeIterator
|
||||
fs_has_free_space, CooperativeIterator, EUCLEAN
|
||||
from swift.common.splice import splice, tee
|
||||
from swift.common.exceptions import DiskFileQuarantined, DiskFileNotExist, \
|
||||
DiskFileCollision, DiskFileNoSpace, DiskFileDeviceUnavailable, \
|
||||
@ -601,7 +601,7 @@ def object_audit_location_generator(devices, datadir, mount_check=True,
|
||||
suffixes = listdir(part_path)
|
||||
except OSError as e:
|
||||
if e.errno not in (errno.ENOTDIR, errno.ENODATA,
|
||||
errno.EUCLEAN):
|
||||
EUCLEAN):
|
||||
raise
|
||||
continue
|
||||
for asuffix in suffixes:
|
||||
@ -610,7 +610,7 @@ def object_audit_location_generator(devices, datadir, mount_check=True,
|
||||
hashes = listdir(suff_path)
|
||||
except OSError as e:
|
||||
if e.errno not in (errno.ENOTDIR, errno.ENODATA,
|
||||
errno.EUCLEAN):
|
||||
EUCLEAN):
|
||||
raise
|
||||
continue
|
||||
for hsh in hashes:
|
||||
@ -1216,7 +1216,7 @@ class BaseDiskFileManager(object):
|
||||
'it is not a directory', {'hsh_path': hsh_path,
|
||||
'quar_path': quar_path})
|
||||
continue
|
||||
elif err.errno in (errno.ENODATA, errno.EUCLEAN):
|
||||
elif err.errno in (errno.ENODATA, EUCLEAN):
|
||||
try:
|
||||
# We've seen cases where bad sectors lead to ENODATA
|
||||
# here; use a similar hack as above
|
||||
@ -1571,7 +1571,7 @@ class BaseDiskFileManager(object):
|
||||
'it is not a directory', {'object_path': object_path,
|
||||
'quar_path': quar_path})
|
||||
raise DiskFileNotExist()
|
||||
elif err.errno in (errno.ENODATA, errno.EUCLEAN):
|
||||
elif err.errno in (errno.ENODATA, EUCLEAN):
|
||||
try:
|
||||
# We've seen cases where bad sectors lead to ENODATA here;
|
||||
# use a similar hack as above
|
||||
@ -2612,7 +2612,7 @@ class BaseDiskFile(object):
|
||||
# want this one file and not its parent.
|
||||
os.path.join(self._datadir, "made-up-filename"),
|
||||
"Expected directory, found file at %s" % self._datadir)
|
||||
elif err.errno in (errno.ENODATA, errno.EUCLEAN):
|
||||
elif err.errno in (errno.ENODATA, EUCLEAN):
|
||||
try:
|
||||
# We've seen cases where bad sectors lead to ENODATA here
|
||||
raise self._quarantine(
|
||||
@ -2642,7 +2642,7 @@ class BaseDiskFile(object):
|
||||
self._fp = self._construct_from_data_file(
|
||||
current_time=current_time, modernize=modernize, **file_info)
|
||||
except IOError as e:
|
||||
if e.errno in (errno.ENODATA, errno.EUCLEAN):
|
||||
if e.errno in (errno.ENODATA, EUCLEAN):
|
||||
raise self._quarantine(
|
||||
file_info['data_file'],
|
||||
"Failed to open %s: %s" % (file_info['data_file'], e))
|
||||
|
@ -36,7 +36,7 @@ from swift.common.utils import whataremyips, unlink_older_than, \
|
||||
rsync_module_interpolation, mkdirs, config_true_value, \
|
||||
config_auto_int_value, storage_directory, \
|
||||
load_recon_cache, PrefixLoggerAdapter, parse_override_options, \
|
||||
distribute_evenly, listdir, node_to_string, parse_options
|
||||
distribute_evenly, listdir, node_to_string, parse_options, EUCLEAN
|
||||
from swift.common.bufferedhttp import http_connect
|
||||
from swift.common.daemon import Daemon, run_daemon
|
||||
from swift.common.http import HTTP_OK, HTTP_INSUFFICIENT_STORAGE
|
||||
@ -620,7 +620,7 @@ class ObjectReplicator(Daemon):
|
||||
tpool.execute(shutil.rmtree, path)
|
||||
except OSError as e:
|
||||
if e.errno not in (errno.ENOENT, errno.ENOTEMPTY, errno.ENODATA,
|
||||
errno.EUCLEAN):
|
||||
EUCLEAN):
|
||||
# Don't worry if there was a race to create or delete,
|
||||
# or some disk corruption that happened after the sync
|
||||
raise
|
||||
|
@ -41,7 +41,8 @@ from gzip import GzipFile
|
||||
import pyeclib.ec_iface
|
||||
|
||||
from eventlet import hubs, timeout, tpool
|
||||
from swift.obj.diskfile import MD5_OF_EMPTY_STRING, update_auditor_status
|
||||
from swift.obj.diskfile import MD5_OF_EMPTY_STRING, update_auditor_status, \
|
||||
EUCLEAN
|
||||
from test import BaseTestCase
|
||||
from test.debug_logger import debug_logger
|
||||
from test.unit import (mock as unit_mock, temptree, mock_check_drive,
|
||||
@ -1830,7 +1831,7 @@ class DiskFileManagerMixin(BaseDiskFileTestMixin):
|
||||
mock.patch(self._manager_mock(
|
||||
'quarantine_renamer')) as quarantine_renamer:
|
||||
osexc = OSError()
|
||||
osexc.errno = errno.EUCLEAN
|
||||
osexc.errno = EUCLEAN
|
||||
cleanup.side_effect = osexc
|
||||
readmeta.return_value = {'name': '/a/c/o'}
|
||||
self.assertRaises(
|
||||
@ -4922,7 +4923,7 @@ class DiskFileMixin(BaseDiskFileTestMixin):
|
||||
|
||||
def my_open(filename, mode, *args, **kwargs):
|
||||
if mode == 'rb':
|
||||
raise IOError(errno.EUCLEAN, '-EUCLEAN fool!')
|
||||
raise IOError(EUCLEAN, '-EUCLEAN fool!')
|
||||
return open(filename, mode, *args, **kwargs)
|
||||
|
||||
with mock.patch('swift.obj.diskfile.open', my_open):
|
||||
@ -4930,7 +4931,7 @@ class DiskFileMixin(BaseDiskFileTestMixin):
|
||||
df.open()
|
||||
self.assertEqual(
|
||||
'Failed to open %s: [Errno %d] -EUCLEAN fool!'
|
||||
% (df._data_file, errno.EUCLEAN), str(err.exception))
|
||||
% (df._data_file, EUCLEAN), str(err.exception))
|
||||
|
||||
def test_quarantine_hashdir_not_a_directory(self):
|
||||
df, df_data = self._create_test_file(b'1234567890', account="abc",
|
||||
@ -4950,7 +4951,7 @@ class DiskFileMixin(BaseDiskFileTestMixin):
|
||||
self.assertTrue(os.path.exists(os.path.dirname(hashdir)))
|
||||
|
||||
def test_quarantine_hashdir_not_listable(self):
|
||||
for eno in (errno.ENODATA, errno.EUCLEAN):
|
||||
for eno in (errno.ENODATA, EUCLEAN):
|
||||
df, df_data = self._create_test_file(b'1234567890', account="abc",
|
||||
container='123', obj='xyz')
|
||||
hashdir = df._datadir
|
||||
@ -8881,7 +8882,7 @@ class TestSuffixHashes(unittest.TestCase):
|
||||
diskfile.clear_auditor_status(tmpdir, 'objects')
|
||||
# EUCLEAN too
|
||||
with mock.patch('os.listdir', splode_if_endswith(
|
||||
"b54", errno.EUCLEAN)):
|
||||
"b54", EUCLEAN)):
|
||||
self.assertEqual(expected, list_locations(tmpdir, 'objects'))
|
||||
diskfile.clear_auditor_status(tmpdir, 'objects')
|
||||
|
||||
@ -8892,7 +8893,7 @@ class TestSuffixHashes(unittest.TestCase):
|
||||
self.assertEqual(expected, list_locations(tmpdir, 'objects'))
|
||||
diskfile.clear_auditor_status(tmpdir, 'objects')
|
||||
with mock.patch('os.listdir', splode_if_endswith(
|
||||
"2809", errno.EUCLEAN)):
|
||||
"2809", EUCLEAN)):
|
||||
self.assertEqual(expected, list_locations(tmpdir, 'objects'))
|
||||
diskfile.clear_auditor_status(tmpdir, 'objects')
|
||||
with mock.patch('os.listdir', splode_if_endswith(
|
||||
@ -8943,7 +8944,7 @@ class TestSuffixHashes(unittest.TestCase):
|
||||
|
||||
def fake_listdir(path):
|
||||
if path == df._datadir:
|
||||
raise OSError(errno.EUCLEAN, 'nope')
|
||||
raise OSError(EUCLEAN, 'nope')
|
||||
return orig_listdir(path)
|
||||
|
||||
df_mgr = self.df_router[policy]
|
||||
|
Loading…
Reference in New Issue
Block a user