Emit warning log in object replicator
When the object-replicator encounters handoffs_first and handoff_delete options as enabled it should emit a log warning indicating that it should be changed back to the default before the next "normal" rebalance. Closes-Bug: #1457262 Change-Id: If9dc2796c18ed3cf13da920831e2d5c2ae9f12a0
This commit is contained in:
parent
ef8f14f2ba
commit
ab163702de
@ -53,13 +53,13 @@ class ObjectReplicator(Daemon):
|
||||
caller to do this in a loop.
|
||||
"""
|
||||
|
||||
def __init__(self, conf):
|
||||
def __init__(self, conf, logger=None):
|
||||
"""
|
||||
:param conf: configuration object obtained from ConfigParser
|
||||
:param logger: logging object
|
||||
"""
|
||||
self.conf = conf
|
||||
self.logger = get_logger(conf, log_route='object-replicator')
|
||||
self.logger = logger or get_logger(conf, log_route='object-replicator')
|
||||
self.devices_dir = conf.get('devices', '/srv/node')
|
||||
self.mount_check = config_true_value(conf.get('mount_check', 'true'))
|
||||
self.vm_test_mode = config_true_value(conf.get('vm_test_mode', 'no'))
|
||||
@ -99,6 +99,10 @@ class ObjectReplicator(Daemon):
|
||||
False))
|
||||
self.handoff_delete = config_auto_int_value(
|
||||
conf.get('handoff_delete', 'auto'), 0)
|
||||
if any((self.handoff_delete, self.handoffs_first)):
|
||||
self.logger.warn('handoffs_first and handoff_delete should be'
|
||||
' changed back to the default before the next'
|
||||
' normal rebalance')
|
||||
self._diskfile_mgr = DiskFileManager(conf, self.logger)
|
||||
|
||||
# Just exists for doc anchor point
|
||||
|
@ -184,6 +184,23 @@ class TestObjectReplicator(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
rmtree(self.testdir, ignore_errors=1)
|
||||
|
||||
def test_handoff_replication_setting_warnings(self):
|
||||
conf = {'handoffs_first': 'true'}
|
||||
replicator = object_replicator.ObjectReplicator(
|
||||
conf, logger=self.logger)
|
||||
self.assertTrue(replicator.handoffs_first)
|
||||
log_message = 'handoffs_first and handoff_delete should'\
|
||||
' be changed back to the default before the'\
|
||||
' next normal rebalance'
|
||||
expected = [log_message]
|
||||
self.assertEqual(self.logger.get_lines_for_level('warning'), expected)
|
||||
conf = {'handoff_delete': '2'}
|
||||
replicator = object_replicator.ObjectReplicator(
|
||||
conf, logger=self.logger)
|
||||
self.assertEqual(replicator.handoff_delete, 2)
|
||||
expected.append(log_message)
|
||||
self.assertEqual(self.logger.get_lines_for_level('warning'), expected)
|
||||
|
||||
def _write_disk_data(self, disk_name):
|
||||
os.mkdir(os.path.join(self.devices, disk_name))
|
||||
objects = os.path.join(self.devices, disk_name,
|
||||
|
Loading…
Reference in New Issue
Block a user