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)