diff options
author | Jenkins <jenkins@review.openstack.org> | 2014-10-03 01:47:32 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2014-10-03 01:47:32 +0000 |
commit | 301e9f532a1c29ff53c6cb1d2edc0144d4832ec8 (patch) | |
tree | bf3f922af1819c6b5f082815efbf1dd1a40c9768 | |
parent | 6d49cc3092168de6d22378557b2c37ea4063beeb (diff) | |
parent | 301a96f664d58b4ccad8e3cbf5d5a889cc76790f (diff) | |
download | swift-301e9f532a1c29ff53c6cb1d2edc0144d4832ec8.tar.gz |
Merge "Ensure sys.exit called in fork_child after exception"
-rw-r--r-- | swift/obj/auditor.py | 8 | ||||
-rw-r--r-- | test/unit/obj/test_auditor.py | 12 |
2 files changed, 18 insertions, 2 deletions
diff --git a/swift/obj/auditor.py b/swift/obj/auditor.py index fce1d85b5..4c78d07af 100644 --- a/swift/obj/auditor.py +++ b/swift/obj/auditor.py @@ -257,8 +257,12 @@ class ObjectAuditor(Daemon): signal.signal(signal.SIGTERM, signal.SIG_DFL) if zero_byte_fps: kwargs['zero_byte_fps'] = self.conf_zero_byte_fps - self.run_audit(**kwargs) - sys.exit() + try: + 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): """Parallel audit loop""" diff --git a/test/unit/obj/test_auditor.py b/test/unit/obj/test_auditor.py index e65beab84..e8f8a2b16 100644 --- a/test/unit/obj/test_auditor.py +++ b/test/unit/obj/test_auditor.py @@ -487,6 +487,18 @@ class TestAuditor(unittest.TestCase): finally: 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): ts_file_path = self.setup_bad_zero_byte(with_ts=True) self.assertTrue(ts_file_path.endswith('ts')) |