Change a debug line to prevent UnicodeDecodeError issue
This debug line is causing tracebacks in the n-cpu logs for tempest runs. Its because the logged data is sometimes unicode: Traceback (most recent call last): File "/usr/lib/python2.7/logging/__init__.py", line 846, in emit msg = self.format(record) File "/opt/stack/new/nova/nova/openstack/common/log.py", line 710, in format return logging.StreamHandler.format(self, record) File "/usr/lib/python2.7/logging/__init__.py", line 723, in format return fmt.format(record) File "/opt/stack/new/nova/nova/openstack/common/log.py", line 674, in format return logging.Formatter.format(self, record) File "/usr/lib/python2.7/logging/__init__.py", line 467, in format s = self._fmt % record.__dict__ UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1234: ordinal not in range(128) Logged from file http.py, line 153 The change used correct encoding error handling policy for the log which may includes non-ascii char. Closes-bug: 1320655 Change-Id: I97f5f14b9beddcceb7fbd371062caf5a38a62a20
This commit is contained in:
parent
3b694ca89f
commit
dec9c9f352
@ -150,7 +150,7 @@ class HTTPClient(object):
|
||||
curl.append('-d \'%s\'' % kwargs['body'])
|
||||
|
||||
curl.append('%s%s' % (self.endpoint, url))
|
||||
LOG.debug(strutils.safe_encode(' '.join(curl)))
|
||||
LOG.debug(strutils.safe_encode(' '.join(curl), errors='ignore'))
|
||||
|
||||
@staticmethod
|
||||
def log_http_response(resp, body=None):
|
||||
|
@ -337,6 +337,16 @@ class TestClient(testtools.TestCase):
|
||||
'timeout': 600.0}
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_log_curl_request_with_non_ascii_char(self):
|
||||
try:
|
||||
headers = {'header1': 'value1\xa5\xa6'}
|
||||
http_client_object = http.HTTPClient(self.endpoint)
|
||||
http_client_object.log_curl_request('GET',
|
||||
'http://www.example.com/\xa5',
|
||||
{'headers': headers})
|
||||
except UnicodeDecodeError as e:
|
||||
self.fail("Unexpected UnicodeDecodeError exception '%s'" % e)
|
||||
|
||||
|
||||
class TestHostResolutionError(testtools.TestCase):
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user