From 0d05a8ff382e7cd64b077730c3d9c314393bf3ef Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Thu, 17 Jun 2021 16:41:20 -0700 Subject: [PATCH] Quiet EPIPE tracebacks Co-Authored-By: Alistair Coles Change-Id: Ibf6cce2447921b58f5a0dff630ea5a0c6284119c --- swift/common/utils.py | 2 ++ test/unit/common/test_utils.py | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/swift/common/utils.py b/swift/common/utils.py index d00cbde4fd..95a5c12b26 100644 --- a/swift/common/utils.py +++ b/swift/common/utils.py @@ -2242,6 +2242,8 @@ class LogAdapter(logging.LoggerAdapter, object): emsg = _('Network unreachable') elif exc.errno == errno.ETIMEDOUT: emsg = _('Connection timeout') + elif exc.errno == errno.EPIPE: + emsg = _('Broken pipe') else: call = self._exception elif isinstance(exc, http_client.BadStatusLine): diff --git a/test/unit/common/test_utils.py b/test/unit/common/test_utils.py index 4f2cabc5d2..18c451b090 100644 --- a/test/unit/common/test_utils.py +++ b/test/unit/common/test_utils.py @@ -1925,6 +1925,18 @@ class TestUtils(unittest.TestCase): self.assertNotIn('Traceback', log_msg) self.assertNotIn('my error message', log_msg) self.assertIn('Connection timeout', log_msg) + + log_exception(socket.error(errno.ENETUNREACH, 'my error message')) + log_msg = strip_value(sio) + self.assertNotIn('Traceback', log_msg) + self.assertNotIn('my error message', log_msg) + self.assertIn('Network unreachable', log_msg) + + log_exception(socket.error(errno.EPIPE, 'my error message')) + log_msg = strip_value(sio) + self.assertNotIn('Traceback', log_msg) + self.assertNotIn('my error message', log_msg) + self.assertIn('Broken pipe', log_msg) # unfiltered log_exception(socket.error(0, 'my error message')) log_msg = strip_value(sio)