fix(seaweedfs)!: clean up orphaned data PVCs and cert/db secrets on tenant module delete (#3092) - #3095
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a SeaweedFS post-delete cleanup hook with dedicated ServiceAccount, RBAC, Job logic, Helm tests, and a phony ChangesSeaweedFS post-delete cleanup hook
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related issues
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a resource leakage issue where SeaweedFS data PVCs and various secrets remained in the cluster after a tenant module was deleted. By implementing a hardened post-delete Helm hook, the system now ensures these orphaned resources are properly garbage-collected, maintaining a cleaner environment and preventing potential storage accumulation. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on Gemini (@gemini-code-assist) comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a post-delete cleanup hook for the SeaweedFS package to remove orphaned PVCs and secrets after the module is disabled, along with corresponding unit tests and a Makefile update. The reviewer feedback suggests removing the restrictive component=volume label filter from the PVC deletion command to ensure that PVCs belonging to custom storage pools or multi-zone topologies are also properly cleaned up, and updating the unit tests accordingly.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/extra/seaweedfs/templates/hooks/cleanup.yaml`:
- Around line 112-120: The cleanup hook’s kubectl delete calls can hang because
they wait for resource deletion by default, so update the SeaweedFS post-delete
cleanup in the hook command to use --wait=false on both the PVC and secret
deletions. Keep the existing logging and ignore-not-found behavior, but ensure
the commands in the cleanup template complete immediately after issuing the
delete request, preventing hook stalls when finalizers block removal.
- Around line 24-26: The PVC cleanup Role is missing the RBAC permission needed
by the cleanup Job’s labeled delete path. Update the persistentvolumeclaims
permissions in the cleanup hook template so the Role used by the Job includes
deletecollection alongside the existing get, list, and delete verbs; this will
let the cleanup shell command that deletes PVCs by label selector work
correctly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ca7caa9f-abbd-4849-be76-2b2ab6cc6a18
📒 Files selected for processing (3)
packages/extra/seaweedfs/Makefilepackages/extra/seaweedfs/templates/hooks/cleanup.yamlpackages/extra/seaweedfs/tests/cleanup_test.yaml
Aleksei Sviridkin (lexfrei)
left a comment
There was a problem hiding this comment.
NOT LGTM — the cleanup is correct and well-tested for the default topology, but the PVC selector silently misses volume PVCs created by custom storage pools and MultiZone topologies, leaving the same leak for those configurations.
Verified the resource names against the rendered chart and the reported leak: the 9 secret names all match, and <release>-system-db-secret carries helm.sh/resource-policy: keep so it genuinely orphans.
Blocker
templates/hooks/cleanup.yaml:117—app.kubernetes.io/component=volumematches only the default volume pool. The volume StatefulSet setsapp.kubernetes.io/componentto{{ $volumeName }}, which the chart computes astrimSuffix "-" (printf "volume-%s" $vname)— so a named pool/zone producesvolume-<name>, which the exactcomponent=volumeselector does not match, and those PVCs stay orphaned (the same bug this PR fixes). Dropping the component clause and keepingapp.kubernetes.io/name=seaweedfs,app.kubernetes.io/instance={{ .Release.Name }}-systemis safe and complete: master/filer use hostPath (no PVCs) and the CNPG db PVCs carrycnpg.io/*labels, so only the volume PVCs match those two labels. The test attests/cleanup_test.yamlpins the current selector and must be updated in lockstep. Because the hook swallows failures (|| echo, the Job always exits 0), a selector miss is permanently silent — selector correctness is the whole gate.
Non-blocking
- The subject is
fix(seaweedfs):, but disabling the module now permanently deletes volume data. The data loss is documented in the body and release note, but please mark it breaking (fix(seaweedfs)!:) for consistency with the sibling cleanup PR. - Consider
--wait=falseon bothkubectl deletecommands; the Job has noactiveDeadlineSeconds, so a PVC stuck on a finalizer could hang the post-delete hook.
The hardening, hook ordering, --ignore-not-found idempotency, and the helm-unittest coverage (incl. the resourceNames-scoped secret RBAC) all look good. Note: the deletecollection verb is not needed — kubectl delete -l does a list + per-object delete, so get,list,delete is sufficient.
cbf862c to
b00ea9b
Compare
|
Aleksei Sviridkin (@lexfrei) thanks for the review — addressed in b00ea9b (force-push): Blocker — PVC selector misses custom pools/MultiZone: dropped the Breaking marker: retitled to
|
ℹ️ E2E failure is fleet-wide infra, not this PRThe red E2E Tests check is unrelated to this change. Only Evidence it is not caused by this PR:
Everything in scope is green: helm unittest 7/7, pre-commit, unit & controller tests, CodeQL, DCO, label, size. Please treat the E2E red as a known CI-environment issue; a re-run will pass once the sandbox cilium problem is resolved. Will rebase onto current main right before merge. |
Aleksei Sviridkin (lexfrei)
left a comment
There was a problem hiding this comment.
LGTM — the prior blocker is resolved; dropping the component clause while keeping name+instance correctly covers every volume topology, and I verified the selector against the chart's StatefulSet labels.
The earlier blocker (the component=volume clause left custom-pool and MultiZone PVCs orphaned) is fixed. Verified against packages/system/seaweedfs/charts/seaweedfs/templates/volume/volume-statefulset.yaml: the volume StatefulSet's spec.selector.matchLabels is {app.kubernetes.io/name=seaweedfs, app.kubernetes.io/instance=<inner-release>, app.kubernetes.io/component=<volumeName>}, and the StatefulSet controller stamps exactly those matchLabels onto each volumeClaimTemplate PVC. So -l app.kubernetes.io/name=seaweedfs,app.kubernetes.io/instance=<release>-system (no component clause) matches volume, volume-<pool>, volume-<zone>, and volume-<zone>-<pool> PVCs across Simple/pool/MultiZone — and uses an exact instance match, so there is no cross-release prefix collision. The 9 by-name secrets match the reported orphan set exactly. --wait=false + activeDeadlineSeconds: 120 keep the hook from blocking teardown. helm-unittest passes (7/7).
Non-blocking follow-ups
- The PR description is stale: it states PVCs are deleted by labels including
app.kubernetes.io/component=volume, but the shipped selector deliberately omits the component clause (and the test asserts it is absent). The body describes the exact bug the code fixes — worth correcting so the merged record is accurate. - No e2e coverage for the cleanup. helm-unittest only pins the rendered command string, not real deletion; seaweedfs has no e2e test today. A toggle-module-off e2e asserting the PVCs/secrets are gone would turn the statically-verified selector into empirical proof and guard against upstream chart label drift.
- The secret cleanup is an explicit by-name list tied to the current upstream chart's cert set. If a future chart bump adds or renames a per-component cert (or enables an auto-generated s3/sftp config secret that is not helm-managed), the hook silently will not reap it. Worth a comment noting the list must track the chart's cert templates.
b00ea9b to
5a3a45b
Compare
…enant module delete (#3092) When the seaweedfs tenant module is disabled, the StatefulSet volume PVCs and a set of certificate/credential secrets were left orphaned. Add a post-delete cleanup hook that deletes the volume PVCs by their release-scoped labels and the secrets by name (all templated from .Release.Name). CNPG PVCs are not targeted (CNPG cleans them). The cleanup Job is hardened (non-root, read-only root fs, dropped caps, resource limits); RBAC scoped via resourceNames; failures are logged, never blocking teardown. The PVC selector matches on name + instance only, without an app.kubernetes.io/component clause, so volume PVCs from custom storage pools and MultiZone topologies (component volume-<pool>/volume-<zone>[-<pool>]) are cleaned up too, not just the default pool. Both deletes use --wait=false and the Job has activeDeadlineSeconds so a finalizer-stuck resource cannot hang the post-delete hook. NOTE: disabling seaweedfs now permanently removes its volume PVCs and the data they hold. BREAKING CHANGE: disabling the seaweedfs tenant module now permanently deletes its volume PVCs and the object data they hold. Back up before disabling if the data matters. Signed-off-by: Алексей Артамонов <aleksei.artamonov@aenix.io>
5a3a45b to
fff2e77
Compare
What this PR does
When the
seaweedfstenant module is disabled, the SeaweedFS StatefulSet data PVCs (data1-<release>-system-volume-*) and a set of certificate/credential secrets were left orphaned in the tenant namespace.This adds a
post-deletecleanup hook (packages/extra/seaweedfs/templates/hooks/cleanup.yaml) that:app.kubernetes.io/name=seaweedfs, app.kubernetes.io/instance=<release>-system, app.kubernetes.io/component=volume);<release>-s3-ingress-tls,<release>-system-{admin,ca,client,filer,master,volume,worker}-cert,<release>-system-db-secret) — cert-manager TLS secrets carry only the cluster-widecontroller.cert-manager.io/fao=truelabel, so they are removed by name rather than by an unsafe label sweep.All names are templated from
.Release.Name(the chart renders the StatefulSet/cert HelmRelease as<release>-system). CNPG PostgreSQL PVCs (<release>-db-*) are intentionally not targeted — CNPG cleans those itself.The cleanup Job is hardened: non-root, read-only root fs, dropped capabilities,
seccompProfile: RuntimeDefault, resource requests/limits; RBAC scoped to PVC get/list/delete and the secrets byresourceNames. Failures are logged but never block teardown.Warning
Disabling the seaweedfs module now permanently deletes its volume data PVCs and the object data they hold. This is intentional and fixes the storage leak. Back up before disabling if the data matters.
Fixes #3092.
Release note
Summary by CodeRabbit
testtarget as phony.