From b3dd6a5df1ac4a5265b330787abcd52c7e116208 Mon Sep 17 00:00:00 2001 From: Christopher Bartz Date: Tue, 3 May 2016 14:33:05 +0200 Subject: [PATCH] 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 --- swift/obj/replicator.py | 7 ++++--- test/unit/obj/test_replicator.py | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/swift/obj/replicator.py b/swift/obj/replicator.py index 7a8613dec7..052213aade 100644 --- a/swift/obj/replicator.py +++ b/swift/obj/replicator.py @@ -642,9 +642,10 @@ class ObjectReplicator(Daemon): if failure_dev]) continue if not found_local: - self.logger.error("Can't find itself %s with port %s in ring " - "file, not replicating", - ", ".join(ips), self.port) + self.logger.error("Can't find itself in policy with index %d with" + " ips %s and with port %s in ring file, not" + " replicating", + int(policy), ", ".join(ips), self.port) return jobs def collect_jobs(self, override_devices=None, override_partitions=None, diff --git a/test/unit/obj/test_replicator.py b/test/unit/obj/test_replicator.py index 38a5f0a2d4..2609e2a60a 100644 --- a/test/unit/obj/test_replicator.py +++ b/test/unit/obj/test_replicator.py @@ -267,10 +267,10 @@ class TestObjectReplicator(unittest.TestCase): logger=self.logger) replicator.run_once() expected = [ - "Can't find itself 1.1.1.1 with port 6200 " - "in ring file, not replicating", - "Can't find itself 1.1.1.1 with port 6200 " - "in ring file, not replicating", + "Can't find itself in policy with index 0 with ips 1.1.1.1 and" + " with port 6200 in ring file, not replicating", + "Can't find itself in policy with index 1 with ips 1.1.1.1 and" + " with port 6200 in ring file, not replicating", ] self.assertEqual(expected, self.logger.get_lines_for_level('error'))