diff --git a/doc/source/deployment_guide.rst b/doc/source/deployment_guide.rst index 81db76a23e..a0250fcabe 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 705926a8df..de1199ea52 100644 --- a/swift/obj/auditor.py +++ b/swift/obj/auditor.py @@ -30,8 +30,6 @@ from swift.common.exceptions import DiskFileQuarantined, DiskFileNotExist from swift.common.daemon import Daemon from swift.common.storage_policy import POLICIES -SLEEP_BETWEEN_AUDITS = 30 - class AuditorWorker(object): """Walk through file system to audit objects""" @@ -240,9 +238,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 23d6a2e19b..b5db2e55e9 100644 --- a/test/unit/obj/test_auditor.py +++ b/test/unit/obj/test_auditor.py @@ -566,10 +566,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):