Improves log message in swift.obj.replicator

Before this commit, when a local device has not found been found
in a object-replication run, the policy was not mentioned in the
error log. But it is of interest to know the policy, for example for
error searching, when no local device has been found.

Change-Id: Icb9f9f1d4aec5c4a70dd8abdf5483d4816720418
This commit is contained in:
Christopher Bartz 2016-05-03 14:33:05 +02:00
parent 2bf5eb775f
commit b3dd6a5df1
2 changed files with 8 additions and 7 deletions

View File

@ -642,9 +642,10 @@ class ObjectReplicator(Daemon):
if failure_dev]) if failure_dev])
continue continue
if not found_local: if not found_local:
self.logger.error("Can't find itself %s with port %s in ring " self.logger.error("Can't find itself in policy with index %d with"
"file, not replicating", " ips %s and with port %s in ring file, not"
", ".join(ips), self.port) " replicating",
int(policy), ", ".join(ips), self.port)
return jobs return jobs
def collect_jobs(self, override_devices=None, override_partitions=None, def collect_jobs(self, override_devices=None, override_partitions=None,

View File

@ -267,10 +267,10 @@ class TestObjectReplicator(unittest.TestCase):
logger=self.logger) logger=self.logger)
replicator.run_once() replicator.run_once()
expected = [ expected = [
"Can't find itself 1.1.1.1 with port 6200 " "Can't find itself in policy with index 0 with ips 1.1.1.1 and"
"in ring file, not replicating", " with port 6200 in ring file, not replicating",
"Can't find itself 1.1.1.1 with port 6200 " "Can't find itself in policy with index 1 with ips 1.1.1.1 and"
"in ring file, not replicating", " with port 6200 in ring file, not replicating",
] ]
self.assertEqual(expected, self.logger.get_lines_for_level('error')) self.assertEqual(expected, self.logger.get_lines_for_level('error'))