From 4a8879a3641540d10121569063aba806abb580e6 Mon Sep 17 00:00:00 2001 From: Alistair Coles Date: Tue, 8 Aug 2023 16:21:28 +0100 Subject: [PATCH] proxy-server: fix AttributeError in exception handler Fix an AttributeError that may be raised during exception handling in the proxy object GET path. GetterBase.node was removed by the RelatedChange. Change-Id: Icf77b9d6b8065814033059e33aca6e98a633dbd4 RelatedChange: I76ea042ef4b3f5cc1caa4774e35d6191f4ca548e --- swift/proxy/controllers/base.py | 2 +- swift/proxy/controllers/obj.py | 2 +- test/unit/proxy/controllers/test_obj.py | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/swift/proxy/controllers/base.py b/swift/proxy/controllers/base.py index 54958a8ca1..ef432ca80d 100644 --- a/swift/proxy/controllers/base.py +++ b/swift/proxy/controllers/base.py @@ -1376,7 +1376,7 @@ class GetOrHeadHandler(GetterBase): part_iter.close() except ChunkReadTimeout: - self.app.exception_occurred(self.node, 'Object', + self.app.exception_occurred(self.source.node, 'Object', 'Trying to read during GET') raise except ChunkWriteTimeout: diff --git a/swift/proxy/controllers/obj.py b/swift/proxy/controllers/obj.py index bd18bf0993..c149623526 100644 --- a/swift/proxy/controllers/obj.py +++ b/swift/proxy/controllers/obj.py @@ -2617,7 +2617,7 @@ class ECFragGetter(GetterBase): part_iter.close() except ChunkReadTimeout: - self.app.exception_occurred(self.node, 'Object', + self.app.exception_occurred(self.source.node, 'Object', 'Trying to read during GET') raise except ChunkWriteTimeout: diff --git a/test/unit/proxy/controllers/test_obj.py b/test/unit/proxy/controllers/test_obj.py index bd17614acb..6252c40944 100644 --- a/test/unit/proxy/controllers/test_obj.py +++ b/test/unit/proxy/controllers/test_obj.py @@ -4538,8 +4538,12 @@ class TestECObjController(ECObjectControllerMixin, unittest.TestCase): self.assertEqual(resp.status_int, 500) self.assertEqual(len(log), self.policy.ec_n_unique_fragments * 2) log_lines = self.app.logger.get_lines_for_level('error') + self.assertEqual(2, len(log_lines), log_lines) + self.assertIn('Trying to read during GET: ChunkReadTimeout', + log_lines[0]) # not the most graceful ending - self.assertIn('Unhandled exception', log_lines[-1]) + self.assertIn('Unhandled exception in request: ChunkReadTimeout', + log_lines[1]) def test_GET_with_multirange_short_resume_body(self): self.app.object_chunk_size = 256