fix(workflow-core): paginate S3 deleteDirectory deletions#5569
Open
kunwp1 wants to merge 3 commits into
Open
Conversation
deleteDirectory issued a single listObjectsV2 call (capped at 1000 keys per page) and one deleteObjects batch, so any objects beyond the first 1000 under a prefix were silently orphaned. AWS DeleteObjects also accepts at most 1000 keys per request, and reports per-key failures in its response rather than throwing. List via listObjectsV2Paginator, which transparently follows the continuation token across all pages, deleting keys in batches of at most 1000. Inspect each DeleteObjects response and raise if any key failed, so partial deletions are no longer swallowed. Also remove the unused MD5 computation (digested over the request's toString and never used). Closes apache#5281
1b4b0c3 to
e3deaba
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5569 +/- ##
=========================================
Coverage 52.17% 52.18%
+ Complexity 2482 2481 -1
=========================================
Files 1068 1068
Lines 41311 41314 +3
Branches 4439 4440 +1
=========================================
+ Hits 21556 21560 +4
Misses 18490 18490
+ Partials 1265 1264 -1
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ry docs - Cap throwOnDeleteErrors enumeration at MAX_LISTED_DELETE_ERRORS (10) and summarize the remainder, so a fully-failed batch can't produce an unbounded message. - Update the LargeBinaryManager doc that still described the pre-pagination single-page (<=1000) behavior of deleteDirectory.
Contributor
Author
|
/request-review @Xiao-zhen-Liu |
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 changes were proposed in this PR?
S3StorageClient.deleteDirectorylisted objects with a singlelistObjectsV2call and issued onedeleteObjectsbatch. Both S3 APIs cap at 1000 keys per call, so for any prefix holding more than 1000 objects only the first 1000 were deleted and the rest causes a storage leak. This affects dataset deletion (DatasetResource) and per-execution cleanup (LargeBinaryManager), either of which can exceed 1000 objects under one prefix.This PR:
listObjectsV2Paginator, which follows the continuation token across all pages, and deletes in batches of at most 1000 keys. Keys are streamed so memory stays bounded to a single batch.DeleteObjectsresponse and throws if any key failed.Any related issues, documentation, discussions?
Closes #5281
How was this PR tested?
for i in {1..1100}; do printf 'x' > "file_$i.txt"; doneWas this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 4.8)