K8SPG-1073: Remove restore_command when backups are disabled#1673
Open
yoav-katz wants to merge 2 commits into
Open
K8SPG-1073: Remove restore_command when backups are disabled#1673yoav-katz wants to merge 2 commits into
yoav-katz wants to merge 2 commits into
Conversation
egegunes
approved these changes
Jul 6, 2026
oksana-grishchenko
approved these changes
Jul 7, 2026
mayankshah1607
approved these changes
Jul 8, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates pgBackRest-related PostgreSQL parameter generation so Patroni does not configure restore_command when backups are disabled, preventing Postgres from attempting (and failing) WAL archive restores when no repository exists.
Changes:
- Omit
restore_commandfrom Patroni mandatory parameters when backups are disabled, unless the user explicitly overrides it. - Add unit test coverage for the “backups disabled” behavior, including override and standby-repo scenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/pgbackrest/postgres.go | Conditionally adds restore_command only when backups are enabled or user-overridden (standby repo still forces it). |
| internal/pgbackrest/postgres_test.go | Adds a test case ensuring restore_command is omitted when backups are disabled, while preserving override and standby behavior. |
Comment on lines
+104
to
+106
| // didn't. Leave restore_command unset so Postgres relies on streaming | ||
| // replication and local WAL only -- unless the user explicitly configured | ||
| // their own restore_command. |
Collaborator
commit: 7387777 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CHANGE DESCRIPTION
Problem:
When
spec.backups.enabled: falseis set, the operator still configures Patroni'srestore_commandto invoke pgBackRest (pgbackrest --stanza=<name> archive-get %f "%p"), even though no backup repository exists. Any time a replica needs a WAL segment it can't get via streaming replication, Postgres calls this command, which fails because there's no valid stanza/repo — instead of falling back cleanly to "no WAL available from archive."Cause:
internal/pgbackrest/postgres.go'sPostgreSQL()function already neutralizesarchive_commandwhen backups are disabled (sets it to a no-optrue), but the equivalent handling was missing forrestore_command— it was built and added to the Patroni mandatory parameter set unconditionally, with nobackupsEnabledcheck at all.Solution:
restore_commandis no longer set when backups are disabled. Unlikearchive_command, it can't simply be pointed at a no-op placeholder liketrue: Postgres treats a zero exit status fromrestore_commandas "the file was placed at %p," so a placeholder that always succeeds would make Postgres believe WAL recovery succeeded when it didn't, risking a crash or silent gap. Instead,restore_commandis omitted entirely in this case, so Postgres relies purely on streaming replication and local WAL. An explicit user override ofrestore_commandviaspec.patroni.dynamicConfigurationis still respected regardless ofbackups.enabled, since that reflects an intentional choice by the user.CHECKLIST
Jira
Needs Doc) and QA (Needs QA)?Tests
Config/Logging/Testability