Skip to content

Commit c5f149b

Browse files
armruleonardoce
andauthored
feat: pass additionalCommandArgs to barman-cloud-restore (#914)
An `ObjectStore` already lets users tack extra command-line flags onto three of the four `barman-cloud-*` invocations: `barman-cloud-backup` via `data.additionalCommandArgs`, `barman-cloud-wal-archive` via `wal.archiveAdditionalCommandArgs`, and `barman-cloud-wal-restore` via `wal.restoreAdditionalCommandArgs`. The fourth — `barman-cloud-restore`, the actual data-restore step in PITR and recovery-from-object-store — has had no equivalent, which is exactly the gap reported in #821 (the asker wanted a longer `--read-timeout` for slow restores from S3). This PR fills that gap by adding `spec.configuration.data.restoreAdditionalCommandArgs` and wiring it into the recovery job hook. In `restoreDataDir`, the user-supplied flags are appended after the cloud-provider options and `--endpoint-url` but before the positional `(destinationPath, serverName, backupID, pgdata)` arguments — same shape as the other three knobs. The library's existing append/dedup logic still wins on conflicts, so users can't accidentally override flags the plugin already sets (`--cloud-provider`, `--endpoint-url`, etc.). Closes #821 Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com> Signed-off-by: Leonardo Cecchi <leonardo.cecchi@gmail.com> Co-authored-by: Leonardo Cecchi <leonardo.cecchi@gmail.com>
1 parent aaf6120 commit c5f149b

4 files changed

Lines changed: 43 additions & 9 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.26.3
55
require (
66
github.com/cert-manager/cert-manager v1.20.2
77
github.com/cloudnative-pg/api v1.29.1
8-
github.com/cloudnative-pg/barman-cloud v0.5.2-0.20260529020047-bb683bf8d82a
8+
github.com/cloudnative-pg/barman-cloud v0.5.2-0.20260603073812-213211ec5e6f
99
github.com/cloudnative-pg/cloudnative-pg v1.29.1
1010
github.com/cloudnative-pg/cnpg-i v0.5.0
1111
github.com/cloudnative-pg/cnpg-i-machinery v0.4.2

go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF
2020
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
2121
github.com/cloudnative-pg/api v1.29.1 h1:FWr8S7EQeOfdhYXyr2cof8wUXLARZiiQt5Qa6ltED7w=
2222
github.com/cloudnative-pg/api v1.29.1/go.mod h1:QtWF3yzSvIfORMHaSkPAk/o3bhCJwEHJgN3riyRiz3o=
23-
github.com/cloudnative-pg/barman-cloud v0.5.2-0.20260529020047-bb683bf8d82a h1:u2Ykj9oCJlJw/xxiCXjG+svTmpaHMcaW6kGNdHdertk=
24-
github.com/cloudnative-pg/barman-cloud v0.5.2-0.20260529020047-bb683bf8d82a/go.mod h1:DACs5rdlMIQ7mUOpJVBRTrbf+d7OGyMOLsFUEMJ2JV8=
23+
github.com/cloudnative-pg/barman-cloud v0.5.2-0.20260513095406-dac43abc6cf6 h1:FxIX5u8Kf1aJQnmW/5eRo+1hx/okApecnIJAmvliaJ8=
24+
github.com/cloudnative-pg/barman-cloud v0.5.2-0.20260513095406-dac43abc6cf6/go.mod h1:VrubJGTgO94O2+m4EX68/wlbDmluc6ITL/VjTcMN3H4=
25+
github.com/cloudnative-pg/barman-cloud v0.5.2-0.20260603073812-213211ec5e6f h1:37XPQQ7PY1tffCXS4QuRK7eSDIzn6oeF8h3cIteN2SE=
26+
github.com/cloudnative-pg/barman-cloud v0.5.2-0.20260603073812-213211ec5e6f/go.mod h1:jCaMsQwJJ0f/49TIdSad1Ayjv52IoJXMZBhozqilY/g=
2527
github.com/cloudnative-pg/cloudnative-pg v1.29.1 h1:ZNEt1TMlnQKXI1kho2UqQuqdfvIvjGln4kN7C1lsmGA=
2628
github.com/cloudnative-pg/cloudnative-pg v1.29.1/go.mod h1:Sbgx9jVmkle4/gR2U5JHrzDd74sRPOBHDtPkvncg5v8=
2729
github.com/cloudnative-pg/cnpg-i v0.5.0 h1:/TOzpNT6cwNgrpftTtrnLKdoHgMwd+88vZgXjlVgXeE=

internal/cnpgi/restore/restore.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ func (impl JobHookImpl) restoreDataDir(
181181
if backup.Status.EndpointURL != "" {
182182
options = append(options, "--endpoint-url", backup.Status.EndpointURL)
183183
}
184+
185+
options = barmanConfiguration.Data.AppendRestoreAdditionalCommandArgs(options)
186+
184187
options = append(options, backup.Status.DestinationPath)
185188
options = append(options, backup.Status.ServerName)
186189
options = append(options, backup.Status.BackupID)

web/docs/misc.md

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,20 @@ spec:
3232
[...]
3333
```
3434

35-
## Extra Options for Backup and WAL Archiving
35+
## Extra Options for Backup, WAL Archiving, and Restore
3636

37-
You can pass additional command-line arguments to `barman-cloud-backup` and
38-
`barman-cloud-wal-archive` using the `additionalCommandArgs` field in the
39-
`ObjectStore` configuration.
37+
You can pass additional command-line arguments to the underlying
38+
`barman-cloud-*` commands using the corresponding fields in the `ObjectStore`
39+
configuration.
4040

4141
- `.spec.configuration.data.additionalCommandArgs`: for `barman-cloud-backup`
42+
- `.spec.configuration.data.restoreAdditionalCommandArgs`: for `barman-cloud-restore`
4243
- `.spec.configuration.wal.archiveAdditionalCommandArgs`: for `barman-cloud-wal-archive`
44+
- `.spec.configuration.wal.restoreAdditionalCommandArgs`: for `barman-cloud-wal-restore`
4345

44-
Each field accepts a list of string arguments. If an argument is already
45-
configured elsewhere in the plugin, the duplicate will be ignored.
46+
Each field accepts a list of string arguments. If an argument conflicts with
47+
one already set by the plugin, the user-provided value will be ignored. These
48+
fields are intended to pass options the plugin does not configure automatically.
4649

4750
### Example: Extra Backup Options
4851

@@ -58,6 +61,19 @@ spec:
5861
- "--read-timeout=60"
5962
```
6063
64+
### Example: Extra Restore Options
65+
66+
```yaml
67+
kind: ObjectStore
68+
metadata:
69+
name: my-store
70+
spec:
71+
configuration:
72+
data:
73+
restoreAdditionalCommandArgs:
74+
- "--read-timeout=900"
75+
```
76+
6177
### Example: Extra WAL Archive Options
6278
6379
```yaml
@@ -72,6 +88,19 @@ spec:
7288
- "--read-timeout=60"
7389
```
7490
91+
### Example: Extra WAL Restore Options
92+
93+
```yaml
94+
kind: ObjectStore
95+
metadata:
96+
name: my-store
97+
spec:
98+
configuration:
99+
wal:
100+
restoreAdditionalCommandArgs:
101+
- "--read-timeout=60"
102+
```
103+
75104
For a complete list of supported options, refer to the
76105
[official Barman Cloud documentation](https://docs.pgbarman.org/release/latest/).
77106

0 commit comments

Comments
 (0)