Merge branch 'master' of github.com:CyberDem0n/governor into features/refactoring

This commit is contained in:
Alexander Kukushkin
2015-05-08 16:33:41 +02:00
2 changed files with 7 additions and 5 deletions
+1 -3
View File
@@ -59,9 +59,7 @@ class Ha:
self.state_handler.follow_the_leader(self.fetch_current_leader())
return "following a different leader because i am not the healthiest node"
else:
if self.has_lock():
self.update_lock()
if self.has_lock() and self.update_lock()
if not self.state_handler.is_leader():
self.state_handler.promote()
return "promoted self to leader because i had the session lock"
+6 -2
View File
@@ -89,8 +89,12 @@ class Postgresql:
os.fchmod(f.fileno(), 0600)
f.write('{hostname}:{port}:*:{username}:{password}\n'.format(**r))
return os.system('PGPASSFILE={pgpass} pg_basebackup -R -D {data_dir} --host={hostname} --port={port} -U {username}'.format(
pgpass=pgpass, data_dir=self.data_dir, **r)) == 0
try:
os.environ['PGPASSFILE'] = pgpass
return os.system('pg_basebackup -R -D {data_dir} --host={hostname} --port={port} -U {username}'.format(
data_dir=self.data_dir, **r)) == 0
finally:
os.environ.pop('PGPASSFILE')
def is_leader(self):
return not self.query('SELECT pg_is_in_recovery()').fetchone()[0]