feat(plugins): plugin controller deletion lifecycle#2014
Open
Zaggy21 wants to merge 10 commits into
Open
Conversation
… Flux failures as status conditions On-behalf-of: @SAP krzysztof.zagorski@sap.com Signed-off-by: Zaggy21 <k.zaggy@gmail.com>
…stamp On-behalf-of: @SAP krzysztof.zagorski@sap.com Signed-off-by: Zaggy21 <k.zaggy@gmail.com>
…ng Plugin deletion (wip) On-behalf-of: @SAP krzysztof.zagorski@sap.com Signed-off-by: Zaggy21 <k.zaggy@gmail.com>
4 tasks
On-behalf-of: @SAP krzysztof.zagorski@sap.com Signed-off-by: Zaggy21 <k.zaggy@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the Plugin controller’s deletion lifecycle to ensure the greenhouse.sap/cleanup finalizer is not removed until Flux has fully completed the HelmRelease uninstall (and to surface Flux uninstall failures on the Plugin status), preventing orphaned Helm resources.
Changes:
- Update
EnsureFluxDeletedto wait for the FluxHelmReleaseto be fully removed, requeue while uninstall is pending, and surfaceUninstallFailedvia Plugin conditions. - Skip Plugin reconciliation when the target Cluster is already being deleted (via
DeletionTimestamp) by requeueing and setting a deletion-related condition. - Add unit + e2e coverage for pending uninstall and uninstall-failure paths during Plugin deletion.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/controller/plugin/util.go | Adds handling to defer reconciliation when the referenced Cluster is already being deleted. |
| internal/controller/plugin/plugin_controller_flux.go | Holds Plugin finalizer until HelmRelease deletion completes; detects Flux uninstall failure and reports it on Plugin conditions. |
| internal/controller/plugin/plugin_controller_flux_test.go | Adds unit tests for pending uninstall and uninstall failure condition surfacing. |
| e2e/plugin/scenarios/flux_controller.go | Adds an e2e scenario that injects HelmRelease uninstall failure and verifies Plugin behavior/finalizer retention. |
| e2e/plugin/e2e_test.go | Registers the new deletion lifecycle e2e scenario. |
| api/v1alpha1/plugin_types.go | Introduces HelmReleaseUninstallPendingReason condition reason constant. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
internal/controller/plugin/plugin_controller_flux_test.go:456
- This Eventually block appends the Flux finalizer on every retry without checking if it’s already present. If the closure retries after a successful update, the finalizer can be duplicated. Consider guarding the append with a contains-check (or use an idempotent patch) to keep the test stable.
By("adding the Flux finalizer to simulate a real Flux-managed HelmRelease")
Eventually(func(g Gomega) {
err := test.K8sClient.Get(test.Ctx, releaseKey, helmRelease)
g.Expect(err).ToNot(HaveOccurred())
helmRelease.Finalizers = append(helmRelease.Finalizers, helmv2.HelmReleaseFinalizer)
err = test.K8sClient.Update(test.Ctx, helmRelease)
g.Expect(err).ToNot(HaveOccurred())
}).Should(Succeed())
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.
Description
Fixes the plugin deletion lifecycle where the greenhouse.sap/cleanup finalizer was removed before Flux had finished running helm uninstall, potentially leaving orphaned Helm resources on the target cluster.
EnsureFluxDeleted now:
What type of PR is this? (check all applicable)
Related Tickets & Documents
Added tests?
Adds unit tests covering the pending and failure paths, and an e2e scenario that injects an uninstall failure via a test finalizer on the HelmRelease and verifies the Plugin surfaces the condition and retains its finalizer until resolved.
Added to documentation?
Checklist