leader variable should be None if the leader.name == my name.

This check has to be performed even check_recovery_conf call
This commit is contained in:
Alexander Kukushkin
2015-10-06 10:07:40 +02:00
parent 601ba7db8d
commit d48f8384ed
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -107,10 +107,10 @@ class Ha:
def follow_the_leader(self, demote_reason, follow_reason, refresh=True):
refresh and self.load_cluster_from_dcs()
ret = demote_reason if self.state_handler.is_leader() else follow_reason
if not self.state_handler.check_recovery_conf(self.cluster.leader):
leader = self.cluster.leader
leader = None if (leader and leader.name) == self.state_handler.name else leader
if not self.state_handler.check_recovery_conf(leader):
self._async_executor.schedule('changing primary_conninfo and restarting')
leader = self.cluster.leader
leader = None if (leader and leader.name) == self.state_handler.name else leader
self._async_executor.run_async(self.state_handler.follow_the_leader, (leader, ))
return ret
+1 -1
View File
@@ -197,7 +197,7 @@ class ZooKeeper(AbstractDCS):
except NoNodeError:
return value == '' or (not index and self._create(self.failover_path, value.encode('utf-8')))
except:
logging.exception('foo')
logging.exception('set_failover_value')
return False
def initialize(self):