Skip to content

[Backport release-1.6] fix(api): keep a suspended HelmRelease suspended across an app update - #4928

Merged
myasnikovdaniil merged 1 commit into
release-1.6from
backport-4411-to-release-1.6
Oct 14, 2026
Merged

myasnikovdaniil merged 1 commit into
release-1.6from
backport-4411-to-release-1.6

Conversation

@myasnikovdaniil

Copy link
Copy Markdown
Contributor

What this PR does

Backport of #4411 to release-1.6.

REST.Update rebuilds the HelmRelease from the Application and writes it back whole, and Application has no suspension, so every edit through the API resumes a release that an operator or a controller suspended. The CNPG restore driver depends on it: it suspends the target release, patches the Postgres app through this API, purges the Cluster and resumes only after the purge, so the next render lands bootstrap.recovery on an empty namespace. When the patch resumes the release, helm-controller upgrades right away, the Cluster gets rendered while the purge still runs, the driver deletes it, and nothing renders it again because the values don't change anymore. RestoreJob stays Running until its deadline.

Why it is needed on this line now. The race was hidden by timing: Update dropped finalizers.fluxcd.io, helm-controller spent its first pass putting it back and requeued, and that delay usually let the purge finish first. #4683 and #4919 keep the finalizer across the write, so the delay is gone. After they landed, postgres-2-backup-roundtrip failed on v1.6.5-rc.1 (https://github.com/cozystack/cozystack/actions/runs/38583543706) and in two earlier PR runs, each time stuck at TargetPurged: Cluster ... deleted; awaiting chart-rendered re-bootstrap. In the snapshot of the rc run the HelmRelease of the restore target upgraded to v2 at 16:16:13Z, the Cluster was deleted at 16:16:22Z, and no Cluster of the target exists afterwards.

The cherry-pick conflicted only in comments of REST.Update, where this branch already has the metadata carry-over. The two Spec.Suspend assignments merged unchanged and the comments read as they do on main.

Validation

  • go build ./... is clean, go vet ./pkg/registry/... is clean, go test ./pkg/registry/... ./internal/backupcontroller/... passes.
  • Removing either Spec.Suspend assignment turns its test red: TestUpdate_PreservesSuspend for the first write, TestUpdate_RefreshesSuspendOnConflictRetry for the conflict retry.
  • Not run here: the restore round trip on a live cluster, the E2E of this PR covers it.

Downstream repositories

It changes how the aggregated API writes the HelmRelease back, no downstream repository restates that.

Release note

fix(api): app edit through cozystack API no longer resumes a suspended HelmRelease, so postgres restore waits for its purge before the cluster is rendered again.

Update rebuilds the HelmRelease from the Application and writes it back
whole, and the Application carries no suspension, so every edit made
through the API resumed a release that an operator or a controller had
suspended.

The CNPG restore driver depends on that suspension. It suspends the
target release, patches the Postgres app through this API, purges the
Cluster, and resumes only once the purge is done, so the chart's next
render lands bootstrap.recovery on an empty namespace. Resumed by the
patch instead, helm-controller upgrades straight away: the chart can
render the recovery Cluster while the purge is still running, the
driver then deletes it as the Cluster being replaced, and nothing
renders it again because the values have not changed since. The
RestoreJob sits in Running until its deadline.

On main this has been masked by timing rather than prevented. The same
write also dropped the Flux finalizer, so helm-controller's first pass
after it only put the finalizer back and requeued, which held the
upgrade back by at least its 750ms minimum retry delay. A branch that
keeps the finalizer removes that delay, and the backup round-trip
failed on both of its runs there.

The suspension is re-read on a conflict retry as well, since the write
that caused the conflict may be the suspend itself.

The conflicts were in the comments of REST.Update, where this branch
already carries the metadata carry-over of the HelmRelease. The two
Spec.Suspend assignments merged unchanged and the comments read as
they do on main.

Assisted-by: LLM
(cherry picked from commit 5df219b)
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
@github-actions github-actions Bot added size/L This PR changes 100-499 lines, ignoring generated files area/api Issues or PRs related to the cozystack-api aggregated API server area/release Issues or PRs related to release tooling (changelog, backport, release pipeline) kind/bug Categorizes issue or PR as related to a bug labels Oct 14, 2026
@coderabbitai

coderabbitai Bot commented Oct 14, 2026

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
  • Configuration used: Repository: cozystack/cozystack/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: df5bb125-2112-4801-a063-e8d191674393

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

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

@myasnikovdaniil
myasnikovdaniil merged commit 234dfda into release-1.6 Oct 14, 2026
43 checks passed
@myasnikovdaniil
myasnikovdaniil deleted the backport-4411-to-release-1.6 branch October 14, 2026 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api Issues or PRs related to the cozystack-api aggregated API server area/release Issues or PRs related to release tooling (changelog, backport, release pipeline) kind/bug Categorizes issue or PR as related to a bug size/L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant