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
This commit is contained in:
Tim Burke
2021-10-22 16:19:09 -07:00
parent a5fbe6ca41
commit 3365998424

View File

@@ -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"))