diff --git a/bin/manage.py b/bin/manage.py index 3a68239..cf5e567 100644 --- a/bin/manage.py +++ b/bin/manage.py @@ -21,6 +21,8 @@ PRIMARY, REPLICA, UNASSIGNED, \ UnknownPrimary, WaitTimeoutError +from manager.discovery import FAILOVER_KEY + class Node(object): """ @@ -84,6 +86,13 @@ def is_primary(self): self.cp.state = PRIMARY return True + # A fail over is happening and I'm the only one left and I got the lock + _, failover_name = self.consul.read_lock(FAILOVER_KEY) + log.debug('failover_name: %s' % failover_name) + if failover_name == self.name: + self.cp.state = PRIMARY + return True + self.cp.state = UNASSIGNED return False