mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Set role to uninitialized if data directory was removed in runtime
Fixes https://github.com/zalando/patroni/issues/542
This commit is contained in:
committed by
Oleksii Kliukin
parent
8e9c62d002
commit
94c52991e0
@@ -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()
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user