summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlistair Coles <alistairncoles@gmail.com>2021-02-19 11:23:29 +0000
committerTim Burke <tim.burke@gmail.com>2021-03-01 16:12:50 -0800
commit87c7684fb09ebb80b08039cc4153f339cb2bdb14 (patch)
tree0dca842f7fb1021fb877d6993fc708f5ec0a2ac8
parent5c3eb488f2df5a93a9899a406fc9a4658efb272b (diff)
downloadswift-87c7684fb09ebb80b08039cc4153f339cb2bdb14.tar.gz
sharder: downgrade 'no data dirs' warning to info
Previously if the sharder found no 'containers' directory on any device then it would emit a warning. This can be a distraction when in normal operation the sharder daemon is run on all nodes including those not in the container ring. This patch clarifies the log message and downgrades it to info level: INFO: Found no containers directories The change also fixes the intermittent failure of the probe test test_delete_root_reclaim in test/probe/test_sharder.pr. The test asserts that no warning logs are emitted, but would previously fail if no containers were created on one of the devices, since the 'Found no data dirs' warning would be emitted. Change-Id: I97f7aa790c225ffd72b77a3fc1a6ef41f72df13e
-rw-r--r--swift/container/sharder.py2
-rw-r--r--test/unit/container/test_sharder.py23
2 files changed, 24 insertions, 1 deletions
diff --git a/swift/container/sharder.py b/swift/container/sharder.py
index d577f0316..dfcc34f2a 100644
--- a/swift/container/sharder.py
+++ b/swift/container/sharder.py
@@ -1872,7 +1872,7 @@ class ContainerSharder(ContainerReplicator):
partitions_to_shard)
dirs.append((datadir, node, part_filt))
if not dirs:
- self.logger.warning('Found no data dirs!')
+ self.logger.info('Found no containers directories')
for part, path, node in self.roundrobin_datadirs(dirs):
# NB: get_part_nodes always provides an 'index' key;
# this will be used in leader selection
diff --git a/test/unit/container/test_sharder.py b/test/unit/container/test_sharder.py
index c89f0eedf..946daeb23 100644
--- a/test/unit/container/test_sharder.py
+++ b/test/unit/container/test_sharder.py
@@ -805,6 +805,29 @@ class TestSharder(BaseTestSharder):
self._assert_stats(
expected_in_progress_stats, sharder, 'sharding_in_progress')
+ def test_one_shard_cycle_no_containers(self):
+ conf = {'recon_cache_path': self.tempdir,
+ 'devices': self.tempdir,
+ 'mount_check': False}
+
+ with self._mock_sharder(conf) as sharder:
+ for dev in sharder.ring.devs:
+ os.mkdir(os.path.join(self.tempdir, dev['device']))
+ with mock.patch('swift.container.sharder.is_local_device',
+ return_value=True):
+ sharder._one_shard_cycle(Everything(), Everything())
+ self.assertEqual([], sharder.logger.get_lines_for_level('warning'))
+ self.assertIn('Found no containers directories',
+ sharder.logger.get_lines_for_level('info'))
+ with self._mock_sharder(conf) as sharder:
+ os.mkdir(os.path.join(self.tempdir, dev['device'], 'containers'))
+ with mock.patch('swift.container.sharder.is_local_device',
+ return_value=True):
+ sharder._one_shard_cycle(Everything(), Everything())
+ self.assertEqual([], sharder.logger.get_lines_for_level('warning'))
+ self.assertNotIn('Found no containers directories',
+ sharder.logger.get_lines_for_level('info'))
+
def test_ratelimited_roundrobin(self):
n_databases = 100