diff --git a/patroni/__init__.py b/patroni/__init__.py index 40801f65..edf6cf10 100644 --- a/patroni/__init__.py +++ b/patroni/__init__.py @@ -129,7 +129,10 @@ class Patroni(object): signal.signal(signal.SIGTERM, self.sigterm_handler) def shutdown(self): - self.api.shutdown() + try: + self.api.shutdown() + except Exception: + logger.exception('Exception during RestApi.shutdown') self.ha.shutdown() diff --git a/tests/test_patroni.py b/tests/test_patroni.py index d4b46589..d3269798 100644 --- a/tests/test_patroni.py +++ b/tests/test_patroni.py @@ -151,3 +151,7 @@ class TestPatroni(unittest.TestCase): self.assertTrue(self.p.nosync) self.p.tags['nosync'] = None self.assertFalse(self.p.nosync) + + def test_shutdown(self): + self.p.api.shutdown = Mock(side_effect=Exception) + self.p.shutdown()