Merge "Quiet more BadStatusLine tracebacks"

This commit is contained in:
Zuul 2022-02-11 05:24:29 +00:00 committed by Gerrit Code Review
commit a846225c39
2 changed files with 18 additions and 2 deletions

View File

@ -71,7 +71,10 @@ import codecs
utf8_decoder = codecs.getdecoder('utf-8')
utf8_encoder = codecs.getencoder('utf-8')
import six
if not six.PY2:
if six.PY2:
from eventlet.green import httplib as green_http_client
else:
from eventlet.green.http import client as green_http_client
utf16_decoder = codecs.getdecoder('utf-16')
utf16_encoder = codecs.getencoder('utf-16')
from six.moves import cPickle as pickle
@ -2242,7 +2245,8 @@ class LogAdapter(logging.LoggerAdapter, object):
emsg = _('Broken pipe')
else:
call = self._exception
elif isinstance(exc, http_client.BadStatusLine):
elif isinstance(exc, (http_client.BadStatusLine,
green_http_client.BadStatusLine)):
# Use error(); not really exceptional
emsg = '%s: %s' % (exc.__class__.__name__, exc.line)
elif isinstance(exc, eventlet.Timeout):

View File

@ -84,6 +84,11 @@ from swift.common.swob import Request, Response
from test.unit import requires_o_tmpfile_support_in_tmp, \
quiet_eventlet_exceptions
if six.PY2:
import eventlet.green.httplib as green_http_client
else:
import eventlet.green.http.client as green_http_client
threading = eventlet.patcher.original('threading')
@ -1989,6 +1994,13 @@ class TestUtils(unittest.TestCase):
self.assertIn('BadStatusLine', log_msg)
self.assertIn("''", log_msg)
# green version is separate :-(
log_exception(green_http_client.BadStatusLine(''))
log_msg = strip_value(sio)
self.assertNotIn('Traceback', log_msg)
self.assertIn('BadStatusLine', log_msg)
self.assertIn("''", log_msg)
# test unhandled
log_exception(Exception('my error message'))
log_msg = strip_value(sio)