Skip to content

fix(backups): clear useSystemBucket on Postgres in-place restore - #3573

Closed
Andrey Kolkov (androndo) wants to merge 1 commit into
mainfrom
fix/postgres-restore-usesystembucket-3327
Closed

Andrey Kolkov (androndo) wants to merge 1 commit into
mainfrom
fix/postgres-restore-usesystembucket-3327

Conversation

@androndo

Copy link
Copy Markdown
Contributor

What this PR does

Fixes #3327.

A Postgres app created with the platform-recommended backup.useSystemBucket=true
flow cannot be restored in place on main. The failure is by construction:

  1. The CNPG restore driver (buildPostgresAppRestorePatch) writes explicit backup
    coordinates onto the target CR (destinationPath / endpointURL /
    s3CredentialsSecret / endpointCA) and flips bootstrap.enabled=true — i.e.
    it converts the app to the explicit-coordinates (legacy) backup flow, which is
    exactly what the chart's bootstrap.recovery + externalClusters block needs.
  2. But the driver never cleared the server-side backup.useSystemBucket=true. The
    partial postgresapp.Backup struct had no such field, so the JSON merge patch
    left it untouched.
  3. On the next render the chart trips its own guard
    (bootstrap.enabled=true is incompatible with backup.useSystemBucket=true,
    packages/apps/postgres/templates/db.yaml). The HelmRelease drops into a
    permanent render-error, bootstrap.recovery never renders, and the RestoreJob
    can never converge — precisely the "cannot converge" symptom in the issue.

Fix: clear backup.useSystemBucket in the restore patch so the chart receives a
self-consistent value set (explicit coordinates, no system-bucket flag, recovery on).
The new postgresapp.Backup.UseSystemBucket field intentionally omits omitempty:
otherwise the false zero-value is dropped from the merge patch, the server's true
survives, and the bug persists. The chart guard is left in place — it is still correct
defensive behavior for a genuinely broken combo; this change stops the driver from
producing that combo.

Verification

  • Unit tests: new TestBuildPostgresAppRestorePatch_ClearsUseSystemBucket asserts both
    the struct flip and that the raw merge patch serializes "useSystemBucket":false
    (guards the omitempty regression directly). Full internal/backupcontroller
    package green; go vet clean.
  • helm template of packages/apps/postgres with the exact values the driver now
    produces (bootstrap.enabled=true, useSystemBucket=false, explicit coords):
    • before / bug (useSystemBucket=true) → render fails on the guard at
      db.yaml:150.
    • after / fixed (useSystemBucket=false) → renders the full recovery topology:
      bootstrap.recovery.source, externalClusters → -recovery ObjectStore, plus the
      ongoing backup ObjectStore.

Screenshots

n/a — controller-internal change, no UI.

Downstream repositories

Walked the trigger map in docs/agents/contributing.md file-by-file against the diff.
The change touches only internal/backupcontroller/ (the CNPG restore driver and its
partial mirror struct) — no CRD (Package/Plan/RestoreJob are untouched), no chart
values (useSystemBucket already exists in the postgres chart), no annotation and no
telemetry metric. Nothing downstream is affected.

  • No downstream repository is affected by this change

Release note

fix(backups): a Postgres application using the platform `backup.useSystemBucket=true` flow can now be restored in place — the CNPG restore driver clears `useSystemBucket` so the chart's bootstrap guard no longer wedges the HelmRelease in a permanent render error.

@github-actions github-actions Bot added size/M This PR changes 30-99 lines, ignoring generated files area/storage Issues or PRs related to storage (linstor, seaweedfs, bucket, velero, harbor) kind/bug Categorizes issue or PR as related to a bug labels Aug 6, 2026
@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

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

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: af2e1369-b0ed-4e73-a535-376dd7877144

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

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

Comment @coderabbitai help to get the list of available commands.

@androndo
Andrey Kolkov (androndo) force-pushed the fix/postgres-restore-usesystembucket-3327 branch 2 times, most recently from dc9b120 to 1f4cae7 Compare August 11, 2026 09:32
A Postgres app created with the platform-recommended backup.useSystemBucket=true
cannot be restored in place. The CNPG restore driver writes explicit backup
coordinates (destinationPath / endpointURL / s3CredentialsSecret) and flips
bootstrap.enabled=true, but it never cleared the server-side
useSystemBucket=true. The chart then fails its `bootstrap.enabled +
useSystemBucket` render guard, the HelmRelease never re-renders
bootstrap.recovery, and the RestoreJob can never converge (helm remediation
retries forever).

Clear backup.useSystemBucket in the restore patch so the chart receives a
self-consistent value set: explicit coordinates, no system-bucket flag,
recovery on. postgresapp.Backup.UseSystemBucket intentionally omits `omitempty`
so the false zero-value survives into the JSON merge patch and actually
overwrites the server value; with omitempty it would be dropped and the bug
would persist.

Signed-off-by: Andrey Kolkov <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@lexfrei

Copy link
Copy Markdown
Contributor

Andrey Kolkov (@androndo) #3959 already resets UseSystemBucket in the CNPG strategy controller, and #3327 is closed as completed. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/storage Issues or PRs related to storage (linstor, seaweedfs, bucket, velero, harbor) kind/bug Categorizes issue or PR as related to a bug size/M This PR changes 30-99 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(backups): platform-flow (useSystemBucket) in-place Postgres restore cannot converge past the chart's bootstrap guard

2 participants