Storage - Fix ImmutableStorageWithVersioningTests Container Cleanup to Handle Soft-Deleted Blobs and Versions#48716
Open
ibrandes wants to merge 7 commits intoAzure:mainfrom
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Improves VLW (Immutable Storage with Versioning) test teardown so containers can be reliably deleted even when blob soft-delete/versioning leaves behind non-current versions, soft-deleted blobs, and snapshots that block container deletion.
Changes:
- Update
cleanupSpecto list versions, deleted blobs (incl. deleted blobs with versions), and snapshots, and delete each item across up to 5 passes. - In teardown, attempt to clear legal holds and immutability policies on each listed item before deletion.
- Add 403 fallback behavior when deleting by version-id is not allowed on the root blob.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ImmutableStorageWithVersioningTests.java | Updates sync VLW teardown to enumerate and remove versions/deleted blobs/snapshots, clear policies, and retry in multiple passes. |
| sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ImmutableStorageWithVersioningAsyncTests.java | Mirrors the same teardown improvements in the async test suite (still using sync clients for cleanup). |
...e-storage-blob/src/test/java/com/azure/storage/blob/ImmutableStorageWithVersioningTests.java
Outdated
Show resolved
Hide resolved
...e-storage-blob/src/test/java/com/azure/storage/blob/ImmutableStorageWithVersioningTests.java
Outdated
Show resolved
Hide resolved
...e-storage-blob/src/test/java/com/azure/storage/blob/ImmutableStorageWithVersioningTests.java
Show resolved
Hide resolved
...e-storage-blob/src/test/java/com/azure/storage/blob/ImmutableStorageWithVersioningTests.java
Show resolved
Hide resolved
...rage-blob/src/test/java/com/azure/storage/blob/ImmutableStorageWithVersioningAsyncTests.java
Show resolved
Hide resolved
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
cleanupSpecnow lists versions, soft-deleted blobs, and snapshots, clears legal holds and immutability policies on each item, deletes them with a 403 fallback for current-version-by-version-id, and repeats for up to five passes so leftover non-current versions do not block container deletion.Problem
With blob soft delete enabled, deleting a blob in a VLW container often leaves non-current versions instead of fully removing data. The previous cleanup used a plain
listBlobspath that did not surface those leftovers, while the service still treats them as blockers—so management cleanup (e.g. deleting the container) can fail with 409 Conflict. The same class of issue motivated the sister PR on the helper script.Approach
BlobListDetailsnow requests versions, deleted blobs, deleted blobs with versions, and snapshots so teardown sees everything that can block deletion.BlobItem, use a snapshot client, version client for non-current versions, or the base blob client as appropriate (CoreUtilsfor version id checks in async tests).setLegalHold(false)anddeleteImmutabilityPolicy(), ignoringBlobStorageExceptionwhen the blob has no hold/policy or is in a state where those APIs are not applicable.deleteIfExists(); if deleting by version id returns 403 (OperationNotAllowedOnRootBlob), fall back to deleting via the base blob client.Files:
ImmutableStorageWithVersioningTests.javaandImmutableStorageWithVersioningAsyncTests.java(sharedcleanupSpeclogic; minor import cleanup where properties/helpers are inlined).