Make object-auditor to use one logger
This commit makes that AuditorWorker gets a logger from ObjectAuditor class (instead of creating new one) so the auditor uses minimum unix-sockets. Fixes: bug #1089215 Change-Id: Ia47d862cbe7505db821784b01fcce6f22196e79f
This commit is contained in:
parent
b8626f9667
commit
d46f90e17a
@ -31,9 +31,9 @@ SLEEP_BETWEEN_AUDITS = 30
|
|||||||
class AuditorWorker(object):
|
class AuditorWorker(object):
|
||||||
"""Walk through file system to audit object"""
|
"""Walk through file system to audit object"""
|
||||||
|
|
||||||
def __init__(self, conf, zero_byte_only_at_fps=0):
|
def __init__(self, conf, logger, zero_byte_only_at_fps=0):
|
||||||
self.conf = conf
|
self.conf = conf
|
||||||
self.logger = get_logger(conf, log_route='object-auditor')
|
self.logger = logger
|
||||||
self.devices = conf.get('devices', '/srv/node')
|
self.devices = conf.get('devices', '/srv/node')
|
||||||
self.mount_check = config_true_value(conf.get('mount_check', 'true'))
|
self.mount_check = config_true_value(conf.get('mount_check', 'true'))
|
||||||
self.max_files_per_second = float(conf.get('files_per_second', 20))
|
self.max_files_per_second = float(conf.get('files_per_second', 20))
|
||||||
@ -224,6 +224,6 @@ class ObjectAuditor(Daemon):
|
|||||||
"""Run the object audit once."""
|
"""Run the object audit once."""
|
||||||
mode = kwargs.get('mode', 'once')
|
mode = kwargs.get('mode', 'once')
|
||||||
zero_byte_only_at_fps = kwargs.get('zero_byte_fps', 0)
|
zero_byte_only_at_fps = kwargs.get('zero_byte_fps', 0)
|
||||||
worker = AuditorWorker(self.conf,
|
worker = AuditorWorker(self.conf, self.logger,
|
||||||
zero_byte_only_at_fps=zero_byte_only_at_fps)
|
zero_byte_only_at_fps=zero_byte_only_at_fps)
|
||||||
worker.audit_all_objects(mode=mode)
|
worker.audit_all_objects(mode=mode)
|
||||||
|
@ -61,7 +61,7 @@ class TestAuditor(unittest.TestCase):
|
|||||||
unit.xattr_data = {}
|
unit.xattr_data = {}
|
||||||
|
|
||||||
def test_object_audit_extra_data(self):
|
def test_object_audit_extra_data(self):
|
||||||
self.auditor = auditor.AuditorWorker(self.conf)
|
self.auditor = auditor.AuditorWorker(self.conf, self.logger)
|
||||||
data = '0' * 1024
|
data = '0' * 1024
|
||||||
etag = md5()
|
etag = md5()
|
||||||
with self.disk_file.mkstemp() as fd:
|
with self.disk_file.mkstemp() as fd:
|
||||||
@ -89,7 +89,7 @@ class TestAuditor(unittest.TestCase):
|
|||||||
self.assertEquals(self.auditor.quarantines, pre_quarantines + 1)
|
self.assertEquals(self.auditor.quarantines, pre_quarantines + 1)
|
||||||
|
|
||||||
def test_object_audit_diff_data(self):
|
def test_object_audit_diff_data(self):
|
||||||
self.auditor = auditor.AuditorWorker(self.conf)
|
self.auditor = auditor.AuditorWorker(self.conf, self.logger)
|
||||||
data = '0' * 1024
|
data = '0' * 1024
|
||||||
etag = md5()
|
etag = md5()
|
||||||
timestamp = str(normalize_timestamp(time.time()))
|
timestamp = str(normalize_timestamp(time.time()))
|
||||||
@ -131,7 +131,7 @@ class TestAuditor(unittest.TestCase):
|
|||||||
fp.write('0' * 1024)
|
fp.write('0' * 1024)
|
||||||
fp.close()
|
fp.close()
|
||||||
invalidate_hash(os.path.dirname(self.disk_file.datadir))
|
invalidate_hash(os.path.dirname(self.disk_file.datadir))
|
||||||
self.auditor = auditor.AuditorWorker(self.conf)
|
self.auditor = auditor.AuditorWorker(self.conf, self.logger)
|
||||||
pre_quarantines = self.auditor.quarantines
|
pre_quarantines = self.auditor.quarantines
|
||||||
self.auditor.object_audit(
|
self.auditor.object_audit(
|
||||||
os.path.join(self.disk_file.datadir, timestamp + '.data'),
|
os.path.join(self.disk_file.datadir, timestamp + '.data'),
|
||||||
@ -139,7 +139,7 @@ class TestAuditor(unittest.TestCase):
|
|||||||
self.assertEquals(self.auditor.quarantines, pre_quarantines + 1)
|
self.assertEquals(self.auditor.quarantines, pre_quarantines + 1)
|
||||||
|
|
||||||
def test_object_audit_bad_args(self):
|
def test_object_audit_bad_args(self):
|
||||||
self.auditor = auditor.AuditorWorker(self.conf)
|
self.auditor = auditor.AuditorWorker(self.conf, self.logger)
|
||||||
pre_errors = self.auditor.errors
|
pre_errors = self.auditor.errors
|
||||||
self.auditor.object_audit(5, 'sda', '0')
|
self.auditor.object_audit(5, 'sda', '0')
|
||||||
self.assertEquals(self.auditor.errors, pre_errors + 1)
|
self.assertEquals(self.auditor.errors, pre_errors + 1)
|
||||||
@ -148,7 +148,7 @@ class TestAuditor(unittest.TestCase):
|
|||||||
self.assertEquals(self.auditor.errors, pre_errors) # just returns
|
self.assertEquals(self.auditor.errors, pre_errors) # just returns
|
||||||
|
|
||||||
def test_object_run_once_pass(self):
|
def test_object_run_once_pass(self):
|
||||||
self.auditor = auditor.AuditorWorker(self.conf)
|
self.auditor = auditor.AuditorWorker(self.conf, self.logger)
|
||||||
self.auditor.log_time = 0
|
self.auditor.log_time = 0
|
||||||
timestamp = str(normalize_timestamp(time.time()))
|
timestamp = str(normalize_timestamp(time.time()))
|
||||||
pre_quarantines = self.auditor.quarantines
|
pre_quarantines = self.auditor.quarantines
|
||||||
@ -169,7 +169,7 @@ class TestAuditor(unittest.TestCase):
|
|||||||
self.assertEquals(self.auditor.quarantines, pre_quarantines)
|
self.assertEquals(self.auditor.quarantines, pre_quarantines)
|
||||||
|
|
||||||
def test_object_run_once_no_sda(self):
|
def test_object_run_once_no_sda(self):
|
||||||
self.auditor = auditor.AuditorWorker(self.conf)
|
self.auditor = auditor.AuditorWorker(self.conf, self.logger)
|
||||||
timestamp = str(normalize_timestamp(time.time()))
|
timestamp = str(normalize_timestamp(time.time()))
|
||||||
pre_quarantines = self.auditor.quarantines
|
pre_quarantines = self.auditor.quarantines
|
||||||
data = '0' * 1024
|
data = '0' * 1024
|
||||||
@ -190,7 +190,7 @@ class TestAuditor(unittest.TestCase):
|
|||||||
self.assertEquals(self.auditor.quarantines, pre_quarantines + 1)
|
self.assertEquals(self.auditor.quarantines, pre_quarantines + 1)
|
||||||
|
|
||||||
def test_object_run_once_multi_devices(self):
|
def test_object_run_once_multi_devices(self):
|
||||||
self.auditor = auditor.AuditorWorker(self.conf)
|
self.auditor = auditor.AuditorWorker(self.conf, self.logger)
|
||||||
timestamp = str(normalize_timestamp(time.time()))
|
timestamp = str(normalize_timestamp(time.time()))
|
||||||
pre_quarantines = self.auditor.quarantines
|
pre_quarantines = self.auditor.quarantines
|
||||||
data = '0' * 10
|
data = '0' * 10
|
||||||
|
Loading…
Reference in New Issue
Block a user