Remove hard-coded values from the failover code.

This commit is contained in:
Oleksii Kliukin
2016-03-04 19:21:48 +01:00
parent aa844b63d0
commit ede5661da3
2 changed files with 3 additions and 2 deletions
+2 -2
View File
@@ -287,10 +287,10 @@ class Ha(object):
try:
delta = (failover.scheduled_at - now).total_seconds()
if delta > 10:
if delta > self.patroni.nap_time:
logging.info('Awaiting failover at %s (in %.0f seconds)', failover.scheduled_at.isoformat(), delta)
return
elif delta < -15:
elif delta < - int(self.patroni.nap_time * 1.5):
logger.warning('Found a stale failover value, cleaning up: %s', failover.scheduled_at)
self.dcs.manual_failover('', '', self.cluster.failover.index)
return
+1
View File
@@ -54,6 +54,7 @@ class MockPatroni(object):
self.api = Mock()
self.tags = {}
self.nofailover = None
self.nap_time = 10
self.replicatefrom = None
self.api.connection_string = 'http://127.0.0.1:8008'