Merge "Cleanup error messages in ECDiskFileWriter.commit"
This commit is contained in:
commit
161231058d
@ -1792,52 +1792,33 @@ class ECDiskFileReader(DiskFileReader):
|
||||
class ECDiskFileWriter(DiskFileWriter):
|
||||
|
||||
def _finalize_durable(self, durable_file_path):
|
||||
exc = msg = None
|
||||
exc = None
|
||||
try:
|
||||
with open(durable_file_path, 'w') as _fp:
|
||||
fsync(_fp.fileno())
|
||||
try:
|
||||
fsync_dir(self._datadir)
|
||||
except OSError as os_err:
|
||||
msg = (_('%s \nProblem fsyncing dir'
|
||||
'after writing .durable: %s') %
|
||||
(os_err, self._datadir))
|
||||
exc = DiskFileError(msg)
|
||||
except IOError as io_err:
|
||||
if io_err.errno in (errno.ENOSPC, errno.EDQUOT):
|
||||
msg = (_('%s \nNo space left on device'
|
||||
'for updates to: %s') %
|
||||
(io_err, self._datadir))
|
||||
exc = DiskFileNoSpace(msg)
|
||||
else:
|
||||
msg = (_('%s \nProblem fsyncing dir'
|
||||
'after writing .durable: %s') %
|
||||
(io_err, self._datadir))
|
||||
exc = DiskFileError(msg)
|
||||
if exc:
|
||||
self.manager.logger.exception(msg)
|
||||
raise exc
|
||||
try:
|
||||
with open(durable_file_path, 'w') as _fp:
|
||||
fsync(_fp.fileno())
|
||||
fsync_dir(self._datadir)
|
||||
except (OSError, IOError) as err:
|
||||
if err.errno not in (errno.ENOSPC, errno.EDQUOT):
|
||||
# re-raise to catch all handler
|
||||
raise
|
||||
msg = (_('No space left on device for %s (%s)') %
|
||||
(durable_file_path, err))
|
||||
self.manager.logger.error(msg)
|
||||
exc = DiskFileNoSpace(str(err))
|
||||
else:
|
||||
try:
|
||||
self.manager.hash_cleanup_listdir(self._datadir)
|
||||
except OSError as os_err:
|
||||
self.manager.logger.exception(
|
||||
_('%s \nProblem cleaning up %s') %
|
||||
(os_err, self._datadir))
|
||||
except OSError as os_err:
|
||||
msg = (_('%s \nProblem fsyncing durable state file: %s') %
|
||||
(os_err, durable_file_path))
|
||||
exc = DiskFileError(msg)
|
||||
except IOError as io_err:
|
||||
if io_err.errno in (errno.ENOSPC, errno.EDQUOT):
|
||||
msg = (_('%s \nNo space left on device for %s') %
|
||||
(io_err, durable_file_path))
|
||||
exc = DiskFileNoSpace(msg)
|
||||
else:
|
||||
msg = (_('%s \nProblem writing durable state file: %s') %
|
||||
(io_err, durable_file_path))
|
||||
exc = DiskFileError(msg)
|
||||
if exc:
|
||||
_('Problem cleaning up %s (%s)') %
|
||||
(self._datadir, os_err))
|
||||
except Exception as err:
|
||||
msg = (_('Problem writing durable state file %s (%s)') %
|
||||
(durable_file_path, err))
|
||||
self.manager.logger.exception(msg)
|
||||
exc = DiskFileError(msg)
|
||||
if exc:
|
||||
raise exc
|
||||
|
||||
def commit(self, timestamp):
|
||||
|
@ -3327,8 +3327,7 @@ class TestECDiskFile(DiskFileMixin, unittest.TestCase):
|
||||
|
||||
# Check IOErrors from fsync_dir() is handled
|
||||
for err_number, expected_exception in scenarios:
|
||||
io_error = IOError()
|
||||
io_error.errno = err_number
|
||||
io_error = IOError(err_number, os.strerror(err_number))
|
||||
mock_open = mock.MagicMock(side_effect=io_error)
|
||||
mock_io_error = mock.MagicMock(side_effect=io_error)
|
||||
df = self._simple_get_diskfile(account='a', container='c',
|
||||
@ -3355,7 +3354,8 @@ class TestECDiskFile(DiskFileMixin, unittest.TestCase):
|
||||
rmtree(df._datadir)
|
||||
|
||||
# Check OSError from fsync_dir() is handled
|
||||
mock_os_error = mock.MagicMock(side_effect=OSError)
|
||||
mock_os_error = mock.MagicMock(
|
||||
side_effect=OSError(100, 'Some Error'))
|
||||
df = self._simple_get_diskfile(account='a', container='c',
|
||||
obj='o_fsync_dir_error')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user