GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(postgres): restore from an archive with the access it was written with by scooby87 · Pull Request #5295 · cozystack/cozystack

Conversation

@scooby87

@scooby87 scooby87 commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

What this PR does

Stacked on #5221; review that one first. Once it merges this PR retargets to main.

A CNPG restore took the destination path and endpoint of the source from the Backup artifact, but the credentials Secret, its key names and the endpoint CA from the CNPG strategy as it reads at restore time. Once the strategy pointed at another bucket or endpoint, the restore combined the recorded location with access settings meant for a different one, and recovery failed after an in-place restore had already purged the target Cluster.

The destination record that #5221 annotates on the cnpg.io/Backup now also carries the key names and the CA, and the artifact copies them into driverMetadata["cnpg.io/archive-access"]. The size probe reads them from there too. The restore picks the access as follows:

  1. While the strategy still points at the same endpoint and S3 bucket as the artifact, the strategy's access is used, exactly as before. WAL archiving keeps proving that access against the archive, and it carries any credential rotation since the backup, after which the recorded Secret may already be revoked. The prefix inside the bucket is not compared, since access is taken to be granted per bucket.
  2. Once the archive has moved, the recorded access is used if its Secret and CA Secret exist and hold non-empty values under the recorded keys.
  3. Otherwise the strategy's access is used, as before, with a RecordedArchiveAccessUnavailable Warning event on the RestoreJob. Credentials wider than one bucket can still read the old archive with it.

An unreadable record fails the RestoreJob, and an error reading a Secret is retried, both before the HelmRelease is suspended and the target is purged. Artifacts written before this change keep working: one that records only the Secret uses it with the strategy's key names and CA once the archive has moved, and one without any record uses the strategy.

This narrows the behaviour the issue asks for ("the recorded Secret, key names and CA, falling back to the strategy only for artifacts that carry no record") in two places, points 1 and 3 above, so that rotating credentials for an archive that has not moved, and deleting the old Secret after a move, keep working as they did. One case remains uncovered: a recorded Secret that still exists but whose keys were revoked, after the archive moved, while the strategy's credentials could still read the old bucket.

Screenshots

Not applicable: no UI change.

Downstream repositories

The diff touches only internal/backupcontroller: no CRD, values, chart or naming change, so nothing in the trigger map applies.

  • No downstream repository is affected by this change
  • cozystack/website - follow-up:
  • cozystack/terraform-provider-cozystack - follow-up:
  • cozystack/ansible-cozystack - follow-up:
  • cozystack/ccp - follow-up:
  • cozystack/talm - follow-up:
  • cozystack/cozyhr - follow-up:
  • cozystack/cozy-proxy - follow-up:
  • cozystack/cozystack-telemetry-server - follow-up:
  • cozystack/external-apps-example - follow-up:
  • cozystack/examples - follow-up:
  • cozystack/community - follow-up:

Release note

fix(postgres): restoring a Postgres backup after its CNPG strategy moved to another bucket or endpoint now reaches the archive with the credentials Secret, key names and CA the backup was written with, as long as those Secrets still exist; otherwise, and for an archive that has not moved, the strategy's current access is used as before.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@scooby87
fix(postgres): restore from an archive with the access it was written…
a130813
… with

A CNPG restore took the destination path and endpoint of the source
from the Backup artifact but the credentials Secret, its key names and
the endpoint CA from the strategy as it reads at restore time. Once the
strategy pointed at another bucket or endpoint, the restore combined the
recorded location with access settings meant for a different one, and
recovery failed after an in-place restore had already purged the target
Cluster.

The destination record on the cnpg.io/Backup now also carries the key
names and the CA, and the artifact copies them. A restore uses them once
the strategy points elsewhere and their Secrets still hold the keys;
otherwise it keeps the strategy's access, as before, which credentials
wider than one bucket can still read the old archive with. While the
strategy points at the same endpoint and bucket its own access is kept:
WAL archiving keeps proving it against that archive, and it carries any
rotation since the backup, after which the recorded Secret may already
be revoked. The size probe reads the recorded access too. An unreadable
record fails the restore before the purge instead of falling back.

Assisted-by: LLM
Signed-off-by: Alexey Artamonov <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: cozystack/cozystack
  • Branch: fix/postgres-backup-objectstore-apply
  • File: .coderabbit.yaml
  • Commit: 5c6fc10
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6272969b-925e-4d5c-9f51-016fc536d966

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

  • X
  • Mastodon
  • Reddit
  • LinkedIn
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added size/XL This PR changes 500-999 lines, ignoring generated files area/database Issues or PRs related to managed databases (postgres, mariadb, redis, etcd, kafka, clickhouse) kind/bug Categorizes issue or PR as related to a bug labels Nov 12, 2026
@scooby87
scooby87 marked this pull request as ready for review November 12, 2026 22:29
@scooby87
scooby87 requested review from IvanHunters, Andrey Kolkov (androndo), Andrei Kvapil (kvaps), Aleksei Sviridkin (lexfrei), Timofei Larkin (lllamnyp), mattia-eleuteri and myasnikovdaniil as code owners November 12, 2026 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@kvaps Andrei Kvapil (kvaps) Awaiting requested review from kvaps kvaps is a code owner
@lllamnyp Timofei Larkin (lllamnyp) Awaiting requested review from lllamnyp lllamnyp is a code owner
@lexfrei Aleksei Sviridkin (lexfrei) Awaiting requested review from lexfrei lexfrei is a code owner
@myasnikovdaniil myasnikovdaniil Awaiting requested review from myasnikovdaniil myasnikovdaniil is a code owner
@IvanHunters IvanHunters Awaiting requested review from IvanHunters IvanHunters is a code owner
@androndo Andrey Kolkov (androndo) Awaiting requested review from androndo androndo is a code owner
@mattia-eleuteri mattia-eleuteri Awaiting requested review from mattia-eleuteri mattia-eleuteri is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

area/database Issues or PRs related to managed databases (postgres, mariadb, redis, etcd, kafka, clickhouse) kind/bug Categorizes issue or PR as related to a bug size/XL This PR changes 500-999 lines, ignoring generated files

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@scooby87
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.