From 918a57fe0c661f1c934f757b50c430376d868bae Mon Sep 17 00:00:00 2001 From: Kostiantyn Nemchenko Date: Fri, 28 Aug 2020 09:23:00 +0300 Subject: [PATCH] Add no_params option for custom bootstrap method (#1664) Close #1475 --- docs/replica_bootstrap.rst | 3 +++ patroni/postgresql/bootstrap.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/replica_bootstrap.rst b/docs/replica_bootstrap.rst index 97c1ccb2..49d44241 100644 --- a/docs/replica_bootstrap.rst +++ b/docs/replica_bootstrap.rst @@ -24,6 +24,7 @@ arguments to them, i.e. the name of the cluster and the path to the data directo : command: [param1 [, ...]] keep_existing_recovery_conf: False + no_params: False recovery_conf: recovery_target_action: promote recovery_target_timeline: latest @@ -40,6 +41,8 @@ in the configuration files, Patroni supplies two cluster-specific ones: --datadir Path to the data directory of the cluster instance to be bootstrapped +Passing these two additional flags can be disabled by setting a special ``no_params`` parameter to ``True``. + If the bootstrap script returns 0, Patroni tries to configure and start the PostgreSQL instance produced by it. If any of the intermediate steps fail, or the script returns a non-zero value, Patroni assumes that the bootstrap has failed, cleans up after itself and releases the initialize lock to give another node the opportunity to bootstrap. diff --git a/patroni/postgresql/bootstrap.py b/patroni/postgresql/bootstrap.py index 01608adc..e5d065dd 100644 --- a/patroni/postgresql/bootstrap.py +++ b/patroni/postgresql/bootstrap.py @@ -98,7 +98,8 @@ class Bootstrap(object): def _custom_bootstrap(self, config): self._postgresql.set_state('running custom bootstrap script') - params = ['--scope=' + self._postgresql.scope, '--datadir=' + self._postgresql.data_dir] + params = [] if config.get('no_params') else ['--scope=' + self._postgresql.scope, + '--datadir=' + self._postgresql.data_dir] try: logger.info('Running custom bootstrap script: %s', config['command']) if self._postgresql.cancellable.call(shlex.split(config['command']) + params) != 0: