From 4940665cea45ec6797755e9cd6fb484116f6b65f Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Tue, 11 Aug 2015 12:01:21 +0200 Subject: [PATCH 1/2] Update dcs.py --- helpers/dcs.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/helpers/dcs.py b/helpers/dcs.py index 0f3e991e..c7140c22 100644 --- a/helpers/dcs.py +++ b/helpers/dcs.py @@ -90,12 +90,12 @@ class AbstractDCS: """Update leader key (or session) ttl and `/optime/leader` key in DCS. :param state_handler: reference to `Postgresql` object - :returns: `!True` if leader lock (or session) has been updated successfully. + :returns: `!True` if leader key (or session) has been updated successfully. If not, `!False` must be returned and current instance would be demoted. If you failed to update `/optime/leader` this error is not critical and you can return `!True` - You have to use CAS operation on order to update leader key, for example for etcd `prevValue` - parameter have to be used.""" + You have to use CAS (Compare And Swap) operation in order to update leader key, + for example for etcd `prevValue` parameter must be used.""" @abc.abstractmethod def attempt_to_acquire_leader(self): @@ -103,7 +103,7 @@ class AbstractDCS: This method should create `/leader` key with value=`~self._name` :returns: `!True` if key has been created successfully. - Key has to be created atomically. In case if key already exists it should not be + Key must be created atomically. In case if key already exists it should not be overwritten and `!False` must be returned""" def current_leader(self): From 29434e24ea79f81729d8e94913848d7e06b4639b Mon Sep 17 00:00:00 2001 From: Oleksii Kliukin Date: Mon, 24 Aug 2015 16:53:57 +0200 Subject: [PATCH 2/2] Allow relative paths to external scripts. --- helpers/postgresql.py | 4 ++-- postgres0.yml | 2 +- tests/test_postgresql.py | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/helpers/postgresql.py b/helpers/postgresql.py index 38f54904..ce8ca18f 100644 --- a/helpers/postgresql.py +++ b/helpers/postgresql.py @@ -145,7 +145,7 @@ class Postgresql: def create_replica(self, master_connection, env): connstring = self.build_connstring(master_connection) - cmd = os.path.abspath(self.config['restore']) + cmd = self.config['restore'] try: ret = subprocess.call(shlex.split(cmd) + [self.scope, "replica", self.data_dir, connstring], env=env) self.delete_trigger_file() @@ -168,7 +168,7 @@ class Postgresql: """ pick a callback command and call it without waiting for it to finish """ if not self.callback or cb_name not in self.callback: return False - cmd = os.path.abspath(self.callback[cb_name]) + cmd = self.callback[cb_name] if is_leader is None: try: is_leader = self.is_leader(check_only=True) diff --git a/postgres0.yml b/postgres0.yml index 200792d5..a2a7ce44 100644 --- a/postgres0.yml +++ b/postgres0.yml @@ -46,7 +46,7 @@ postgresql: env_dir: /home/postgres/etc/wal-e.d/env threshold_megabytes: 10240 threshold_backup_size_percentage: 30 - restore: /usr/bin/true + restore: "true" #recovery_conf: #restore_command: cp ../wal_archive/%f %p parameters: diff --git a/tests/test_postgresql.py b/tests/test_postgresql.py index 6cbb6cb7..c4a3d6df 100644 --- a/tests/test_postgresql.py +++ b/tests/test_postgresql.py @@ -118,9 +118,9 @@ class TestPostgresql(unittest.TestCase): 'password': 'rep-pass', 'network': '127.0.0.1/32'}, 'parameters': {'foo': 'bar'}, 'recovery_conf': {'foo': 'bar'}, - 'callbacks': {'on_start': '/usr/bin/true', 'on_stop': '/usr/bin/true', - 'on_restart': '/usr/bin/true', 'on_role_change': '/bin/true', - 'on_reload': '/usr/bin/true' + 'callbacks': {'on_start': 'true', 'on_stop': 'true', + 'on_restart': 'true', 'on_role_change': 'true', + 'on_reload': 'true' }, 'restore': '/usr/bin/true'}) psycopg2.connect = psycopg2_connect