Skip to content

feat: honor the operator's check_empty_wal_archive decision#1009

Open
mnencia wants to merge 3 commits into
mainfrom
dev/check-empty-wal-archive
Open

feat: honor the operator's check_empty_wal_archive decision#1009
mnencia wants to merge 3 commits into
mainfrom
dev/check-empty-wal-archive

Conversation

@mnencia

@mnencia mnencia commented Jul 16, 2026

Copy link
Copy Markdown
Member

Archive() and the restore job hook each re-derived, on their own, whether to verify the WAL archive destination is empty, by reading a Cluster annotation and, for Archive, an on-disk marker file. That decision belongs to the operator, which already tracks both the annotation and the marker file's lifecycle.

Honor cnpg-i's new WALArchiveRequest/RestoreRequest field CheckEmptyWalArchive when the operator sets it: obey it directly, without re-inspecting the marker file. Only fall back to the previous annotation-and-marker-file logic when talking to an operator that predates this field.

Related: cloudnative-pg/cnpg-i#353 adds the field this depends on; cloudnative-pg/cloudnative-pg#11216 is the operator-side counterpart.

@mnencia
mnencia requested a review from a team as a code owner July 16, 2026 16:58
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request go Pull requests that update go code labels Jul 16, 2026
@mnencia
mnencia force-pushed the dev/check-empty-wal-archive branch 2 times, most recently from 23d9092 to 19a4121 Compare July 16, 2026 17:08
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 17, 2026
mnencia and others added 3 commits July 17, 2026 18:16
Archive() and the restore job hook each re-derived, on their own,
whether to verify the WAL archive destination is empty, by reading a
Cluster annotation and, for Archive, an on-disk marker file. That
decision belongs to the operator, which already tracks both the
annotation and the marker file's lifecycle.

Honor cnpg-i's new WALArchiveRequest/RestoreRequest field
CheckEmptyWalArchive when the operator sets it: obey it directly,
without re-inspecting the marker file. Only fall back to the previous
annotation-and-marker-file logic when talking to an operator that
predates this field.

Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
The WAL archive hook and the restore job hook each derived, inline,
whether to verify the archive destination before proceeding. Pull each
decision into a small function so the operator-decision-versus-fallback
logic can be exercised on its own. Behavior is unchanged: archiving still
fails on a marker-file stat error, and restore still falls back to the
Cluster annotation alone.

Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
Add unit coverage for the WAL archive and restore-job decision helpers.
The tables pin the version-skew contract: when the operator sets the
decision it overrides both the Cluster annotation and, for archiving, the
on-disk marker file, while a nil decision (an operator that predates the
field) reproduces the previous annotation-based behavior.

Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
@mnencia
mnencia force-pushed the dev/check-empty-wal-archive branch from 959f6bd to 664f808 Compare July 17, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update go code lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants