From 336599842481f449833515ea96b3c616f4ae39c5 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Fri, 22 Oct 2021 16:19:09 -0700 Subject: [PATCH] Fix log message interpolation Seen in a lab cluster (though I'm fairly certain I've also seen it in prod): STDERR: Traceback (most recent call last): STDERR: File ".../logging/handlers.py", line 860, in emit STDERR: msg = self.format(record) + '\000' STDERR: File ".../logging/__init__.py", line 741, in format STDERR: return fmt.format(record) STDERR: File ".../swift/common/utils.py", line 2299, in format STDERR: record.message = record.getMessage() STDERR: File ".../logging/__init__.py", line 329, in getMessage STDERR: msg = msg % self.args STDERR: TypeError: %d format: a number is required, not unicode STDERR: Logged from file replicator.py, line 596 (And since it was sent out via STDERR, yeah, the formatting was pretty horrible.) Change-Id: Ibe139a4d303079b5b803a76b270e1366f09dc534 --- swift/obj/replicator.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/swift/obj/replicator.py b/swift/obj/replicator.py index a3a65e526c..97350ca870 100644 --- a/swift/obj/replicator.py +++ b/swift/obj/replicator.py @@ -592,9 +592,10 @@ class ObjectReplicator(Daemon): self.delete_partition(job['path']) handoff_partition_deleted = True except PartitionLockTimeout: - self.logger.info("Unable to lock handoff partition %d for " + self.logger.info("Unable to lock handoff partition %s for " "replication on device %s policy %d", - job['partition'], job['device'], job['policy']) + job['partition'], job['device'], + int(job['policy'])) self.logger.increment('partition.lock-failure.count') except (Exception, Timeout): self.logger.exception(_("Error syncing handoff partition"))