From 9c16830fc056adb9df0b80c1797b83f977c21350 Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Wed, 11 Nov 2015 10:46:37 +0100 Subject: [PATCH] Do not fail when there is no postgresql/parameters section in a config file --- patroni/postgresql.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/patroni/postgresql.py b/patroni/postgresql.py index 1ad69719..de51b3f2 100644 --- a/patroni/postgresql.py +++ b/patroni/postgresql.py @@ -42,6 +42,7 @@ class Postgresql: def __init__(self, config): self.config = config self.name = config['name'] + self.server_parameters = config.get('parameters', {}) self.scope = config['scope'] self.listen_addresses, self.port = config['listen'].split(':') self.data_dir = config['data_dir'] @@ -323,7 +324,7 @@ class Postgresql: def server_options(self): options = "--listen_addresses='{}' --port={}".format(self.listen_addresses, self.port) - for setting, value in self.config['parameters'].items(): + for setting, value in self.server_parameters.items(): options += " --{}='{}'".format(setting, value) return options @@ -341,7 +342,7 @@ class Postgresql: with open(os.path.join(self.data_dir, 'pg_hba.conf'), 'a') as f: f.write('\nhost replication {username} {network} md5\n'.format(**self.replication)) for line in self.config.get('pg_hba', []): - if line.split()[0].strip() == 'hostssl' and self.config['parameters'].get('ssl', 'off').lower() != 'on': + if line.split()[0].strip() == 'hostssl' and self.server_parameters.get('ssl', 'off').lower() != 'on': continue f.write(line + '\n')