Merge "Obj Auditor: Quarantine ENODATA"
This commit is contained in:
commit
3d7ff12064
@ -2540,8 +2540,14 @@ class BaseDiskFile(object):
|
||||
self._data_file = file_info.get('data_file')
|
||||
if not self._data_file:
|
||||
raise self._construct_exception_from_ts_file(**file_info)
|
||||
try:
|
||||
self._fp = self._construct_from_data_file(
|
||||
current_time=current_time, modernize=modernize, **file_info)
|
||||
except IOError as e:
|
||||
if e.errno == errno.ENODATA:
|
||||
raise self._quarantine(
|
||||
file_info['data_file'],
|
||||
"Failed to open %s: %s" % (file_info['data_file'], e))
|
||||
# This method must populate the internal _metadata attribute.
|
||||
self._metadata = self._metadata or {}
|
||||
return self
|
||||
|
@ -4649,6 +4649,21 @@ class DiskFileMixin(BaseDiskFileTestMixin):
|
||||
DiskFileQuarantined,
|
||||
self._get_open_disk_file)
|
||||
|
||||
def test_quarantine_ioerror_enodata(self):
|
||||
df = self._get_open_disk_file()
|
||||
|
||||
def my_open(filename, mode, *args, **kwargs):
|
||||
if mode == 'rb':
|
||||
raise IOError(errno.ENODATA, '-ENODATA fool!')
|
||||
return open(filename, mode, *args, **kwargs)
|
||||
|
||||
with mock.patch('swift.obj.diskfile.open', my_open):
|
||||
with self.assertRaises(DiskFileQuarantined) as err:
|
||||
df.open()
|
||||
self.assertEqual(
|
||||
'Failed to open %s: [Errno 61] -ENODATA fool!' % df._data_file,
|
||||
str(err.exception))
|
||||
|
||||
def test_quarantine_hashdir_not_a_directory(self):
|
||||
df, df_data = self._create_test_file(b'1234567890', account="abc",
|
||||
container='123', obj='xyz')
|
||||
|
Loading…
Reference in New Issue
Block a user