Fix bug in kubernetes.update_leader (#1685)

Unhandled exception prevented demoting the primary.
In addition to that wrap the update_leader call in the HA loop into try..except block and implement a test case.

Fixes https://github.com/zalando/patroni/issues/1684
This commit is contained in:
Alexander Kukushkin
2020-09-11 10:19:03 +02:00
committed by GitHub
parent 0a1f389686
commit 4dd902fbf1
3 changed files with 8 additions and 3 deletions
+2 -1
View File
@@ -200,7 +200,8 @@ class TestHa(PostgresInit):
def test_update_lock(self):
self.p.last_operation = Mock(side_effect=PostgresConnectionException(''))
self.assertTrue(self.ha.update_lock(True))
self.ha.dcs.update_leader = Mock(side_effect=Exception)
self.assertFalse(self.ha.update_lock(True))
@patch.object(Postgresql, 'received_timeline', Mock(return_value=None))
def test_touch_member(self):