mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Patroni doesn't filter out some not allowed options from pg_basebackup (#3015)
When running `pg_basebackup` to bootstrap a replica, Patroni sanitizes
the custom user options that come from `postgresql.basebackup` configuration
section using the `process_user_options` method.
However, there is a bug in that method: it filters out not allowed options
that are in the format `- setting`, but not the ones in the format
`- setting: value` from `postgresql.basebackup`.
An example of that issue is the `dbname` setting. If you specify something
like this in the configuration file:
```yaml
postgresql:
basebackup:
- dbname: "host=RANDOM"
```
You end up with `--dbname` being specified twice for `pg_basebackup`, with
`--dbname='host=RANDOM'` taking precedence as it comes up later in the
command.
This commit fixes that issue by adding a `continue` statement when
the setting in format `- setting: value` is not allowed, thus skipping
it.
---------
Signed-off-by: Israel Barth Rubio <[email protected]>
This commit is contained in:
@@ -142,6 +142,16 @@ class TestBootstrap(BaseTestPostgresql):
|
||||
(), error_handler
|
||||
),
|
||||
["--key=value with spaces"])
|
||||
# not allowed options in list of dicts/strs are filtered out
|
||||
self.assertEqual(
|
||||
self.b.process_user_options(
|
||||
'pg_basebackup',
|
||||
[{'checkpoint': 'fast'}, {'dbname': 'dbname=postgres'}, 'gzip', {'label': 'standby'}, 'verbose'],
|
||||
('dbname', 'verbose'),
|
||||
print
|
||||
),
|
||||
['--checkpoint=fast', '--gzip', '--label=standby'],
|
||||
)
|
||||
|
||||
@patch.object(CancellableSubprocess, 'call', Mock())
|
||||
@patch.object(Postgresql, 'is_running', Mock(return_value=True))
|
||||
|
||||
Reference in New Issue
Block a user