Merge "container-updater: log LockTimeout exceptions at INFO, not ERROR"

This commit is contained in:
Zuul
2018-05-30 18:14:54 +00:00
committed by Gerrit Code Review
2 changed files with 10 additions and 13 deletions

View File

@@ -239,9 +239,10 @@ class ContainerUpdater(Daemon):
broker = ContainerBroker(dbfile, logger=self.logger) broker = ContainerBroker(dbfile, logger=self.logger)
try: try:
info = broker.get_info() info = broker.get_info()
except LockTimeout: except LockTimeout as e:
self.logger.exception("Failed to get container info for %s", self.logger.info(
dbfile) "Failed to get container info (Lock timeout: %s); skipping.",
str(e))
return return
# Don't send updates if the container was auto-created since it # Don't send updates if the container was auto-created since it
# definitely doesn't have up to date statistics. # definitely doesn't have up to date statistics.

View File

@@ -160,22 +160,18 @@ class TestContainerUpdater(unittest.TestCase):
os.mkdir(containers_dir) os.mkdir(containers_dir)
subdir = os.path.join(containers_dir, 'subdir') subdir = os.path.join(containers_dir, 'subdir')
os.mkdir(subdir) os.mkdir(subdir)
cb = ContainerBroker(os.path.join(subdir, 'hash.db'), account='a', db_file = os.path.join(subdir, 'hash.db')
container='c') cb = ContainerBroker(db_file, account='a', container='c')
cb.initialize(normalize_timestamp(1), 0) cb.initialize(normalize_timestamp(1), 0)
timeout = exceptions.LockTimeout(10) timeout = exceptions.LockTimeout(10, db_file)
timeout.cancel() timeout.cancel()
with mock.patch('swift.container.updater.ContainerBroker.get_info', with mock.patch('swift.container.updater.ContainerBroker.get_info',
side_effect=timeout): side_effect=timeout):
cu.run_once() cu.run_once()
log_lines = self.logger.get_lines_for_level('error') log_lines = self.logger.get_lines_for_level('info')
self.assertTrue(log_lines) self.assertIn('Failed to get container info (Lock timeout: '
self.assertIn('Failed to get container info ', log_lines[0]) '10 seconds: %s); skipping.' % db_file, log_lines)
self.assertIn('devices/sda1/containers/subdir/hash.db', log_lines[0])
self.assertIn('LockTimeout (10s)', log_lines[0])
self.assertFalse(log_lines[1:])
self.assertEqual(1, len(mock_dump_recon.mock_calls))
@mock.patch('swift.container.updater.dump_recon_cache') @mock.patch('swift.container.updater.dump_recon_cache')
@mock.patch('swift.container.updater.ContainerUpdater.process_container', @mock.patch('swift.container.updater.ContainerUpdater.process_container',