Handle exception from Ha.shutdown (#1351)

During the shutdown Patroni is trying to update its status in the DCS.
If the DCS is inaccessible an exception might be raised. Lack of exception handling prevents logger thread from stopping.

Fixes https://github.com/zalando/patroni/issues/1344
This commit is contained in:
Alexander Kukushkin
2020-01-16 14:34:58 +01:00
committed by GitHub
parent c5fc6fd936
commit 1c4d395d5a
2 changed files with 5 additions and 1 deletions
+4 -1
View File
@@ -159,7 +159,10 @@ class Patroni(object):
self.api.shutdown()
except Exception:
logger.exception('Exception during RestApi.shutdown')
self.ha.shutdown()
try:
self.ha.shutdown()
except Exception:
logger.exception('Exception during Ha.shutdown')
self.logger.shutdown()
+1
View File
@@ -174,6 +174,7 @@ class TestPatroni(unittest.TestCase):
@patch.object(Thread, 'join', Mock())
def test_shutdown(self):
self.p.api.shutdown = Mock(side_effect=Exception)
self.p.ha.shutdown = Mock(side_effect=Exception)
self.p.shutdown()
def test_check_psycopg2(self):