diff --git a/doc/source/deployment_guide.rst b/doc/source/deployment_guide.rst index f06afc483b..1ae7887636 100644 --- a/doc/source/deployment_guide.rst +++ b/doc/source/deployment_guide.rst @@ -719,6 +719,8 @@ log_facility LOG_LOCAL0 Syslog log facility log_level INFO Logging level log_address /dev/log Logging directory log_time 3600 Frequency of status logs in seconds. +interval 30 Time in seconds to wait between + auditor passes disk_chunk_size 65536 Size of chunks read during auditing files_per_second 20 Maximum files audited per second per auditor process. Should be tuned according diff --git a/etc/object-server.conf-sample b/etc/object-server.conf-sample index 815b63cc5d..a7921a68ad 100644 --- a/etc/object-server.conf-sample +++ b/etc/object-server.conf-sample @@ -282,6 +282,9 @@ use = egg:swift#recon # log_level = INFO # log_address = /dev/log # +# Time in seconds to wait between auditor passes +# interval = 30 +# # You can set the disk chunk size that the auditor uses making it larger if # you like for more efficient local auditing of larger objects # disk_chunk_size = 65536 diff --git a/swift/obj/auditor.py b/swift/obj/auditor.py index 38fef209e1..72016143aa 100644 --- a/swift/obj/auditor.py +++ b/swift/obj/auditor.py @@ -29,8 +29,6 @@ from swift.common.utils import get_logger, ratelimit_sleep, dump_recon_cache, \ from swift.common.exceptions import DiskFileQuarantined, DiskFileNotExist from swift.common.daemon import Daemon -SLEEP_BETWEEN_AUDITS = 30 - class AuditorWorker(object): """Walk through file system to audit objects""" @@ -230,9 +228,10 @@ class ObjectAuditor(Daemon): self.recon_cache_path = conf.get('recon_cache_path', '/var/cache/swift') self.rcache = os.path.join(self.recon_cache_path, "object.recon") + self.interval = int(conf.get('interval', 30)) def _sleep(self): - time.sleep(SLEEP_BETWEEN_AUDITS) + time.sleep(self.interval) def clear_recon_cache(self, auditor_type): """Clear recon cache entries""" diff --git a/test/unit/obj/test_auditor.py b/test/unit/obj/test_auditor.py index 3de4cf239d..26acd967d5 100644 --- a/test/unit/obj/test_auditor.py +++ b/test/unit/obj/test_auditor.py @@ -533,10 +533,20 @@ class TestAuditor(unittest.TestCase): def test_sleeper(self): with mock.patch( 'time.sleep', mock.MagicMock()) as mock_sleep: - auditor.SLEEP_BETWEEN_AUDITS = 0.10 my_auditor = auditor.ObjectAuditor(self.conf) my_auditor._sleep() - mock_sleep.assert_called_with(auditor.SLEEP_BETWEEN_AUDITS) + mock_sleep.assert_called_with(30) + + my_conf = dict(interval=2) + my_conf.update(self.conf) + my_auditor = auditor.ObjectAuditor(my_conf) + my_auditor._sleep() + mock_sleep.assert_called_with(2) + + my_auditor = auditor.ObjectAuditor(self.conf) + my_auditor.interval = 2 + my_auditor._sleep() + mock_sleep.assert_called_with(2) def test_run_parallel_audit(self):