From 6b863310e5e09b4ee1c8cd7184b72b7bd78a5afc Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Fri, 21 Dec 2018 10:41:57 -0600 Subject: [PATCH] Handle string status codes in logging Observed on "too many database connections" the following error in the log: Error formatting log line msg=u'*(url)s returned with HTTP *(status)d' err=TypeError('*d format: a number is required, not str',) This was due to the format string using %d where somehow the result code was actually a string. Since formatting numbers works with %s, and is actually sometimes more performant, this just switches %d to %s to be more flexible. Change-Id: I52d6fb46c5ab0f2fa24c629697daaf39d35584c3 Signed-off-by: Sean McGinnis --- cinder/api/middleware/fault.py | 2 +- cinder/api/openstack/wsgi.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cinder/api/middleware/fault.py b/cinder/api/middleware/fault.py index e170b4c4633..862fe25e481 100644 --- a/cinder/api/middleware/fault.py +++ b/cinder/api/middleware/fault.py @@ -60,7 +60,7 @@ class FaultWrapper(base_wsgi.Middleware): status = http_client.INTERNAL_SERVER_ERROR msg_dict = dict(url=req.url, status=status) - LOG.info("%(url)s returned with HTTP %(status)d", msg_dict) + LOG.info("%(url)s returned with HTTP %(status)s", msg_dict) outer = self.status_to_type(status) if headers: outer.headers = headers diff --git a/cinder/api/openstack/wsgi.py b/cinder/api/openstack/wsgi.py index 21428791f52..2c9d78a42b8 100644 --- a/cinder/api/openstack/wsgi.py +++ b/cinder/api/openstack/wsgi.py @@ -936,7 +936,7 @@ class Resource(wsgi.Application): try: msg_dict = dict(url=request.url, status=response.status_int) - msg = "%(url)s returned with HTTP %(status)d" + msg = "%(url)s returned with HTTP %(status)s" except AttributeError as e: msg_dict = dict(url=request.url, e=e) msg = "%(url)s returned a fault: %(e)s"