Set role to uninitialized if data directory was removed in runtime

Fixes https://github.com/zalando/patroni/issues/542
This commit is contained in:
Alexander Kukushkin
2017-10-12 15:03:13 +02:00
committed by Oleksii Kliukin
parent 8e9c62d002
commit 94c52991e0
2 changed files with 2 additions and 0 deletions
+1
View File
@@ -1014,6 +1014,7 @@ class Ha(object):
# is data directory empty?
if self.state_handler.data_directory_empty():
self.state_handler.set_role('uninitialized')
# In case datadir went away while we were master. TODO: check for this and try to stop postgresql.
self.watchdog.disable()
+1
View File
@@ -862,6 +862,7 @@ class TestHa(unittest.TestCase):
self.ha.has_lock = true
self.p.data_directory_empty = true
self.assertEquals(self.ha.run_cycle(), 'released leader key voluntarily as data dir empty and currently leader')
self.assertEquals(self.p.role, 'uninitialized')
# as has_lock is mocked out, we need to fake the leader key release
self.ha.has_lock = false