Avoid stopping pg instance when in paused state

This commit is contained in:
Murat Kabilov
2016-08-23 11:38:30 +02:00
parent b5d6b7d13d
commit c50f072b31
2 changed files with 7 additions and 3 deletions
+4 -1
View File
@@ -128,5 +128,8 @@ def main():
pass
finally:
patroni.api.shutdown()
patroni.postgresql.stop(checkpoint=False)
if patroni.ha.is_paused():
logger.info('Postgres is not stopped due paused state')
else:
patroni.postgresql.stop(checkpoint=False)
patroni.dcs.delete_leader()
+3 -2
View File
@@ -26,6 +26,9 @@ class Ha(object):
self.recovering = False
self._async_executor = AsyncExecutor()
def is_paused(self):
return self.cluster.config and 'pause' in self.cluster.config.data and self.cluster.config.data['pause']
def load_cluster_from_dcs(self):
cluster = self.dcs.get_cluster()
@@ -150,8 +153,6 @@ class Ha(object):
if self.state_handler.is_leader() or self.state_handler.role == 'master':
return message
else:
if self.cluster.config and 'pause' in self.cluster.config.data and self.cluster.config.data['pause']:
return "Not promoted due to paused state."
self.state_handler.promote()
self.touch_member()
return promote_message