From a642860ae8d0798f8d4145b2778bf9d988567f42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Mart=C3=ADnez?= Date: Thu, 1 Sep 2016 17:06:33 +0200 Subject: [PATCH] Turn _configuration_to_save into a property method --- patroni/postgresql.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/patroni/postgresql.py b/patroni/postgresql.py index a189acc4..0baff425 100644 --- a/patroni/postgresql.py +++ b/patroni/postgresql.py @@ -102,11 +102,6 @@ class Postgresql(object): self._postgresql_base_conf = os.path.join(self._data_dir, self._postgresql_base_conf_name) self._postgresql_custom_conf = config.get('custom_conf') self._recovery_conf = os.path.join(self._data_dir, 'recovery.conf') - self._configuration_to_save = [self._postgresql_conf] - if not self._postgresql_custom_conf: - self._configuration_to_save.append(self._postgresql_base_conf) - if not config['parameters'].get('hba_file'): - self._configuration_to_save.append(os.path.join(self._data_dir, 'pg_hba.conf')) self._postmaster_pid = os.path.join(self._data_dir, 'postmaster.pid') self._trigger_file = config.get('recovery_conf', {}).get('trigger_file') or 'promote' self._trigger_file = os.path.abspath(os.path.join(self._data_dir, self._trigger_file)) @@ -128,6 +123,15 @@ class Postgresql(object): self.set_role('master' if self.is_leader() else 'replica') self._write_postgresql_conf() # we are "joining" already running postgres + @property + def _configuration_to_save(self): + configuration = [self._postgresql_conf] + if not self._postgresql_custom_conf: + configuration.append(self._postgresql_base_conf) + if not self.config['parameters'].get('hba_file'): + configuration.append(os.path.join(self._data_dir, 'pg_hba.conf')) + return configuration + @property def use_slots(self): return self._use_slots and self._major_version >= 9.4