Autodetect the host role during start from the existence of recovery.conf. Fix some typos.

This commit is contained in:
Oleksii Kliukin
2015-06-03 16:18:47 +02:00
parent e06cd49deb
commit fb3bf799e9
2 changed files with 2 additions and 4 deletions
-2
View File
@@ -44,14 +44,12 @@ class Governor:
self.postgresql.start()
self.postgresql.create_replication_user()
self.postgresql.create_connection_users()
self.aws.on_role_change('master')
else:
while True:
leader = self.etcd.current_leader()
if leader and self.postgresql.sync_from_leader(leader):
self.postgresql.write_recovery_conf(leader)
self.postgresql.start()
self.aws.on_role_change('replica')
break
sleep(5)
elif self.postgresql.is_running():
+2 -2
View File
@@ -47,7 +47,7 @@ class AWSConnection:
try:
conn = boto.ec2.connect_to_region(self.region)
# get all volumes attached to the current instance
volumes = conn.get_all_volumes(filter={'attachment.instance-id': self.instance_id})
volumes = conn.get_all_volumes(filters={'attachment.instance-id': self.instance_id})
if volumes:
conn.create_tags([v.id for v in volumes], tags)
except Exception as e:
@@ -64,7 +64,7 @@ class AWSConnection:
conn = boto.ec2.connect_to_region(self.region)
instances = conn.get_all_reservations(instance_ids=[self.instance_id])
if instances:
conn.create_tag([instances[0].id], tags)
conn.create_tags([instances[0].id], tags)
except Exception as e:
logger.info("could not set tags for EC2 instance {}: {}".format(self.instance_id, e))
return False