Cover case when failover is now and via DCS (#320)

Fix the bug with setting failover directly in DCS via patronictl. Fix by @Sulion
This commit is contained in:
Sulion
2016-09-21 17:01:27 +02:00
committed by Oleksii Kliukin
parent 5265e71fc2
commit e7329fb903
+4 -3
View File
@@ -590,12 +590,13 @@ def failover(config_file, cluster_name, master, candidate, force, dcs, scheduled
scheduled_at = parse_scheduled(scheduled)
scheduled_at_str = None
if scheduled_at:
if cluster.is_paused():
raise PatroniCtlException("Can't schedule failover in the paused state")
scheduled_at = scheduled_at.isoformat()
scheduled_at_str = scheduled_at.isoformat()
failover_value = {'leader': master, 'candidate': candidate, 'scheduled_at': scheduled_at}
failover_value = {'leader': master, 'candidate': candidate, 'scheduled_at': scheduled_at_str}
logging.debug(failover_value)
@@ -628,7 +629,7 @@ def failover(config_file, cluster_name, master, candidate, force, dcs, scheduled
logging.warning('Failing over to DCS')
click.echo(timestamp() + ' Could not failover using Patroni api, falling back to DCS')
click.echo(timestamp() + ' Initializing failover from master {0}'.format(master))
dcs.manual_failover(master, candidate, scheduled_at=failover_value)
dcs.manual_failover(master, candidate, scheduled_at=scheduled_at)
output_members(cluster, cluster_name)