fix(fsx): stream directory entries in RemoveContents to avoid memory spike on large BN PVs#775
Merged
Merged
Conversation
Signed-off-by: dosi <dosi.kolev@limechain.tech>
Signed-off-by: dosi <dosi.kolev@limechain.tech>
Signed-off-by: dosi <dosi.kolev@limechain.tech>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates filesystem cleanup logic to avoid memory spikes when deleting very large directories by switching from os.ReadDir (reads entire listing) to bounded batched reads via (*os.File).ReadDir(256). It applies the same pattern both to fsx.Manager.RemoveContents and to the cluster uninstall cleanup step, and adds a unit test to exercise multi-batch behavior.
Changes:
- Stream directory entries in
pkg/fsx/unixManager.RemoveContentsusingReadDir(removeContentsBatchSize)batches. - Update
CleanupWeaverFilesto iterate/opt/solo/weaverentries in batches while preserving skip-dirs + best-effort teardown behavior. - Add
TestUnixManager_RemoveContents_MultipleBatchesto cover removal across multiple full batches.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/fsx/manager_unix.go | Reworks RemoveContents to open the directory and remove entries while iterating in fixed-size ReadDir batches. |
| internal/workflows/steps/step_cluster_uninstall.go | Switches weaver-home cleanup to batched directory reads and keeps teardown best-effort semantics. |
| pkg/fsx/manager_unix_test.go | Adds a new test ensuring RemoveContents works correctly across multiple ReadDir batches. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: dosi <dosi.kolev@limechain.tech>
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
This pull request changes the following:
pkg/fsx/manager_unix.go—RemoveContentsnow streams directory entries in boundedbatches via
(*os.File).ReadDir(256)instead of loading the whole listing withos.ReadDir, keeping memory usage constant on large block node PVs.internal/workflows/steps/step_cluster_uninstall.go— thecleanup-weaver-filesstepuses the same batched read pattern for consistency, preserving its skip-dirs and
best-effort teardown behavior.
pkg/fsx/manager_unix_test.go— addsTestUnixManager_RemoveContents_MultipleBatches,which exercises the batched loop across more than two full batches.
Related Issues