Skip to content

Storage - Fix ImmutableStorageWithVersioningTests Container Cleanup to Handle Soft-Deleted Blobs and Versions#48716

Open
ibrandes wants to merge 7 commits intoAzure:mainfrom
ibrandes:storage/fixImmutableStorageWVersioningTests
Open

Storage - Fix ImmutableStorageWithVersioningTests Container Cleanup to Handle Soft-Deleted Blobs and Versions#48716
ibrandes wants to merge 7 commits intoAzure:mainfrom
ibrandes:storage/fixImmutableStorageWVersioningTests

Conversation

@ibrandes
Copy link
Copy Markdown
Member

@ibrandes ibrandes commented Apr 7, 2026

Summary

cleanupSpec now 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 listBlobs path 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

  • Listing: BlobListDetails now requests versions, deleted blobs, deleted blobs with versions, and snapshots so teardown sees everything that can block deletion.
  • Targeting: For each BlobItem, use a snapshot client, version client for non-current versions, or the base blob client as appropriate (CoreUtils for version id checks in async tests).
  • Policy cleanup: Unconditionally call setLegalHold(false) and deleteImmutabilityPolicy(), ignoring BlobStorageException when the blob has no hold/policy or is in a state where those APIs are not applicable.
  • Deletion: Use deleteIfExists(); if deleting by version id returns 403 (OperationNotAllowedOnRootBlob), fall back to deleting via the base blob client.
  • Passes: Up to five rounds because each round can expose new non-current versions that need the same treatment.

Files: ImmutableStorageWithVersioningTests.java and ImmutableStorageWithVersioningAsyncTests.java (shared cleanupSpec logic; minor import cleanup where properties/helpers are inlined).

@github-actions github-actions bot added the Storage Storage Service (Queues, Blobs, Files) label Apr 7, 2026
@ibrandes ibrandes changed the title Storage - Storage - Fix ImmutableStorageWithVersioningTests Container Cleanup to Handle Soft-Deleted Blobs and Versions Apr 7, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 cleanupSpec to 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).

@ibrandes ibrandes marked this pull request as ready for review April 8, 2026 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Storage Storage Service (Queues, Blobs, Files)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants