mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Make create_replica_method a YAML array.
Make sure the absense of this key or empty value in it is handled correctly. Update tests and sample configuration files.
This commit is contained in:
@@ -240,9 +240,9 @@ class Postgresql:
|
||||
# defined by the user. this is a list, so we need to
|
||||
# loop through all methods the user supplies
|
||||
connstring = leader.conn_url
|
||||
# get list of replica methods from config
|
||||
replica_list = self.config.get('create_replica_method', 'basebackup')
|
||||
replica_methods = [rm.strip() for rm in replica_list.split(',')]
|
||||
# get list of replica methods from config.
|
||||
# If there is no configuration key, or no value is specified, use basebackup
|
||||
replica_methods = self.config.get('create_replica_method') or ['basebackup']
|
||||
# go through them in priority order
|
||||
ret = 1
|
||||
for replica_method in replica_methods:
|
||||
|
||||
+3
-1
@@ -68,7 +68,9 @@ postgresql:
|
||||
admin:
|
||||
username: admin
|
||||
password: admin
|
||||
create_replica_method: basebackup
|
||||
create_replica_method:
|
||||
- basebackup
|
||||
# - wal_e
|
||||
# commented-out example for wal-e provisioning
|
||||
#create_replica_method: wal_e, basebackup
|
||||
#wal_e:
|
||||
|
||||
+4
-1
@@ -69,7 +69,10 @@ postgresql:
|
||||
username: admin
|
||||
password: admin
|
||||
# commented-out example for wal-e provisioning
|
||||
#create_replica_method: wal_e, basebackup
|
||||
create_replica_method:
|
||||
- basebackup
|
||||
# - wal_e
|
||||
# commented-out example for wal-e provisioning
|
||||
#wal_e:
|
||||
#command: /patroni/scripts/wale_restore.py
|
||||
#env_dir: /home/postgres/etc/wal-e.d/env
|
||||
|
||||
@@ -284,7 +284,7 @@ class TestPostgresql(unittest.TestCase):
|
||||
with patch('subprocess.call', Mock(side_effect=[Exception(), 0])):
|
||||
self.assertEquals(self.p.create_replica(self.leader, ''), 0)
|
||||
|
||||
self.p.config['create_replica_method'] = 'wale, basebackup'
|
||||
self.p.config['create_replica_method'] = ['wale', 'basebackup']
|
||||
self.p.config['wale'] = {'command': 'foo'}
|
||||
with patch('subprocess.call', Mock(return_value=0)):
|
||||
self.assertEquals(self.p.create_replica(self.leader, ''), 0)
|
||||
|
||||
Reference in New Issue
Block a user