mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Fix annoying exceptions on ssl socket shutdown (#2468)
The HAProxy is closing connections as soon as it got the HTTP Status code leaving no time for Patroni to properly shutdown SSL connection. Close https://github.com/zalando/patroni/issues/2466
This commit is contained in:
+4
-1
@@ -845,7 +845,10 @@ class RestApiServer(ThreadingMixIn, HTTPServer, Thread):
|
||||
|
||||
def shutdown_request(self, request):
|
||||
if hasattr(request, 'context'): # SSLSocket
|
||||
request.unwrap()
|
||||
try:
|
||||
request.unwrap()
|
||||
except Exception as e:
|
||||
logger.debug('Failed to shutdown SSL connection: %r', e)
|
||||
super(RestApiServer, self).shutdown_request(request)
|
||||
|
||||
def get_certificate_serial_number(self):
|
||||
|
||||
+5
-2
@@ -601,8 +601,11 @@ class TestRestApiServer(unittest.TestCase):
|
||||
self.srv.process_request_thread(Mock(), '2')
|
||||
|
||||
@patch.object(MockRestApiServer, 'process_request', Mock(side_effect=RuntimeError))
|
||||
@patch.object(MockRestApiServer, 'get_request', Mock(return_value=(Mock(), ('127.0.0.1', 55555))))
|
||||
def test_process_request_error(self):
|
||||
@patch.object(MockRestApiServer, 'get_request')
|
||||
def test_process_request_error(self, mock_get_request):
|
||||
mock_request = Mock()
|
||||
mock_request.unwrap.side_effect = Exception
|
||||
mock_get_request.return_value = (mock_request, ('127.0.0.1', 55555))
|
||||
self.srv._handle_request_noblock()
|
||||
|
||||
@patch('ssl._ssl._test_decode_cert', Mock())
|
||||
|
||||
Reference in New Issue
Block a user