Merge "Ensure sys.exit called in fork_child after exception"
This commit is contained in:
commit
301e9f532a
@ -257,8 +257,12 @@ class ObjectAuditor(Daemon):
|
|||||||
signal.signal(signal.SIGTERM, signal.SIG_DFL)
|
signal.signal(signal.SIGTERM, signal.SIG_DFL)
|
||||||
if zero_byte_fps:
|
if zero_byte_fps:
|
||||||
kwargs['zero_byte_fps'] = self.conf_zero_byte_fps
|
kwargs['zero_byte_fps'] = self.conf_zero_byte_fps
|
||||||
self.run_audit(**kwargs)
|
try:
|
||||||
sys.exit()
|
self.run_audit(**kwargs)
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.error(_("ERROR: Unable to run auditing: %s") % e)
|
||||||
|
finally:
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
def audit_loop(self, parent, zbo_fps, override_devices=None, **kwargs):
|
def audit_loop(self, parent, zbo_fps, override_devices=None, **kwargs):
|
||||||
"""Parallel audit loop"""
|
"""Parallel audit loop"""
|
||||||
|
@ -487,6 +487,18 @@ class TestAuditor(unittest.TestCase):
|
|||||||
finally:
|
finally:
|
||||||
auditor.diskfile.DiskFile = was_df
|
auditor.diskfile.DiskFile = was_df
|
||||||
|
|
||||||
|
@mock.patch.object(auditor.ObjectAuditor, 'run_audit')
|
||||||
|
@mock.patch('os.fork', return_value=0)
|
||||||
|
def test_with_inaccessible_object_location(self, mock_os_fork,
|
||||||
|
mock_run_audit):
|
||||||
|
# Need to ensure that any failures in run_audit do
|
||||||
|
# not prevent sys.exit() from running. Otherwise we get
|
||||||
|
# zombie processes.
|
||||||
|
e = OSError('permission denied')
|
||||||
|
mock_run_audit.side_effect = e
|
||||||
|
self.auditor = auditor.ObjectAuditor(self.conf)
|
||||||
|
self.assertRaises(SystemExit, self.auditor.fork_child, self)
|
||||||
|
|
||||||
def test_with_tombstone(self):
|
def test_with_tombstone(self):
|
||||||
ts_file_path = self.setup_bad_zero_byte(with_ts=True)
|
ts_file_path = self.setup_bad_zero_byte(with_ts=True)
|
||||||
self.assertTrue(ts_file_path.endswith('ts'))
|
self.assertTrue(ts_file_path.endswith('ts'))
|
||||||
|
Loading…
Reference in New Issue
Block a user