revert some changes which changed functionality of original code

This commit is contained in:
Alexander Kukushkin
2016-02-15 13:41:50 +01:00
parent 58508c3404
commit 31bad6df49
2 changed files with 10 additions and 5 deletions
+7 -3
View File
@@ -112,6 +112,12 @@ class Ha(object):
def follow(self, demote_reason, follow_reason, refresh=True, recovery=False):
if refresh:
self.load_cluster_from_dcs()
if not recovery and self.state_handler.is_leader() or recovery and self.state_handler.role == 'master':
ret = demote_reason
else:
ret = follow_reason
# determine the node to follow. If replicatefrom tag is set,
# try to follow the node mentioned there, otherwise, follow the leader.
if self.patroni.replicatefrom:
@@ -123,9 +129,7 @@ class Ha(object):
if not self.state_handler.check_recovery_conf(node_to_follow) or recovery:
self._async_executor.schedule('changing primary_conninfo and restarting')
self._async_executor.run_async(self.state_handler.follow, (node_to_follow, recovery))
if not recovery and self.state_handler.is_leader() or recovery and self.state_handler.role == 'master':
return demote_reason
return follow_reason
return ret
def enforce_master_role(self, message, promote_message):
if self.state_handler.is_leader() or self.state_handler.role == 'master':
+3 -2
View File
@@ -392,8 +392,9 @@ class Postgresql(object):
# patroni.
self.close_connection()
if not self.is_running() and not block_callbacks:
self.set_state('stopped')
if not self.is_running():
if not block_callbacks:
self.set_state('stopped')
return True
if block_callbacks: