Repository navigation
[Backport release-1.6] fix(api): keep a suspended HelmRelease suspended across an app update - #4928
Merged
Merged
Conversation
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>
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
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.
What this PR does
Backport of #4411 to
release-1.6.REST.Updaterebuilds 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 landsbootstrap.recoveryon 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 staysRunninguntil 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-roundtripfailed on v1.6.5-rc.1 (https://github.com/cozystack/cozystack/actions/runs/38583543706) and in two earlier PR runs, each time stuck atTargetPurged: 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 twoSpec.Suspendassignments 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.Spec.Suspendassignment turns its test red:TestUpdate_PreservesSuspendfor the first write,TestUpdate_RefreshesSuspendOnConflictRetryfor the conflict retry.Downstream repositories
It changes how the aggregated API writes the HelmRelease back, no downstream repository restates that.
Release note