feat: add l8k clean command - #160
Merged
Merged
Conversation
Add l8k clean to remove custom resources from the resolved operator namespace, sweep known cluster-scoped Network Operator policies, and uninstall the Helm release last. Support retaining the Helm release with --keep-helm-chart and document the cleanup boundary for operators and agents. Signed-off-by: Alexander Maslennikov <amaslennikov@nvidia.com>
Greptile SummaryThe PR adds the destructive
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the previously reported attacker-controlled Helm Secret namespace-selection path has been removed. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[l8k clean] --> B[Resolve kubeconfig]
B --> C[Resolve namespace from flag or local config]
C --> D[Confirm destructive cleanup]
D --> E[List namespaced custom resources]
E --> F[List known cluster-scoped resources]
F --> G[Delete resources and wait for finalizers]
G --> H[Re-scan and delete recreated resources]
H --> I{keep-helm-chart?}
I -->|Yes| J[Keep Helm release]
I -->|No| K[Uninstall Helm release]
J --> L[Emit cleanup result]
K --> L
Reviews (2): Last reviewed commit: "fix: require a trusted cleanup namespace" | Re-trigger Greptile |
Do not infer the destructive cleanup target from user-creatable Helm release Secrets. Resolve only from an explicit flag, trusted local config, or the standard namespace default. Signed-off-by: Alexander Maslennikov <amaslennikov@nvidia.com>
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.
Summary
Safety and idempotency
The command resolves the full initial CR deletion set before mutating the cluster, waits for finalizers while controllers are still installed, and treats missing CRDs, resources, and Helm releases as successful no-ops. Text mode requires confirmation; JSON mode follows the existing subcommand convention and auto-confirms. --keep-helm-chart skips Helm uninstall without narrowing CR cleanup.
Custom installation namespaces must be passed explicitly or recorded in trusted local config. Cleanup does not trust user-creatable Helm release Secrets to choose its target.
Validation
No live cluster cleanup was run as part of development.