mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-09-01 00:59:24 +00:00
Clear the scheduled restart after the normal one.
Make sure the scheduled restart flag is cleared when the postmaster_start_time changes since the time restart was scheduled. Additionally, separate the logic of checking the restart conditions into the function in order to support conditions for the normal restart as well.
This commit is contained in:
+6
-1
@@ -26,6 +26,10 @@ class MockPostgresql(object):
|
||||
def connection():
|
||||
return psycopg2_connect()
|
||||
|
||||
@staticmethod
|
||||
def postmaster_start_time():
|
||||
return '2016-08-20 12:00TZ+1'
|
||||
|
||||
|
||||
class MockHa(object):
|
||||
|
||||
@@ -67,7 +71,8 @@ class MockPatroni(object):
|
||||
tags = {}
|
||||
version = '0.00'
|
||||
noloadbalance = Mock(return_value=False)
|
||||
scheduled_restart = {'schedule': dateutil.parser.parse('2016-08-29 12:45TZ+1')}
|
||||
scheduled_restart = {'schedule': dateutil.parser.parse('2016-08-29 12:45TZ+1'),
|
||||
'postmaster_start_time': '2016-08-20 12:00TZ+1'}
|
||||
|
||||
@staticmethod
|
||||
def sighup_handler():
|
||||
|
||||
+4
-1
@@ -81,7 +81,8 @@ zookeeper:
|
||||
self.replicatefrom = None
|
||||
self.api.connection_string = 'http://127.0.0.1:8008'
|
||||
self.clonefrom = None
|
||||
self.scheduled_restart = {'schedule': dateutil.parser.parse('2016-08-29 12:45TZ+1')}
|
||||
self.scheduled_restart = {'schedule': dateutil.parser.parse('2016-08-29 12:45TZ+1'),
|
||||
'postmaster_start_time': '2016-08-20 12:00TZ+1'}
|
||||
|
||||
|
||||
def run_async(func, args=()):
|
||||
@@ -119,6 +120,7 @@ class TestHa(unittest.TestCase):
|
||||
'hot_standby': 'on', 'max_wal_senders': 5, 'wal_keep_segments': 8}})
|
||||
self.p.set_state('running')
|
||||
self.p.set_role('replica')
|
||||
self.p.postmaster_start_time = MagicMock(return_value="2016-08-20 12:00TZ+1")
|
||||
self.p.check_replication_lag = true
|
||||
self.p.can_create_replica_without_replication_connection = MagicMock(return_value=False)
|
||||
self.e = get_dcs({'etcd': {'ttl': 30, 'host': 'ok:2379', 'scope': 'test',
|
||||
@@ -128,6 +130,7 @@ class TestHa(unittest.TestCase):
|
||||
self.ha.old_cluster = self.e.get_cluster()
|
||||
self.ha.cluster = get_cluster_not_initialized_without_leader()
|
||||
self.ha.load_cluster_from_dcs = Mock()
|
||||
#self.ha.evaluate_scheduled_restart = true
|
||||
|
||||
def test_update_lock(self):
|
||||
self.p.last_operation = Mock(side_effect=PostgresException(''))
|
||||
|
||||
Reference in New Issue
Block a user