Skip to content

Commit

Permalink
Delete the lease-detection blob after the migration for the asset is …
Browse files Browse the repository at this point in the history
…done
  • Loading branch information
weibz committed Jul 28, 2023
1 parent f55b3e3 commit 79363b8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions azure/AzureStorageUploader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,17 @@ public async Task UploadCleanupAsync(
CancellationToken cancellationToken)
{
var lockBlob = await GetLockBlobAsync(containerName, outputPath, cancellationToken);
var leaseClient = lockBlob.GetBlobLeaseClient(_leaseId);

await leaseClient.ReleaseAsync(cancellationToken: cancellationToken);
// The lease is guaranteed to hold by this tool, the migration work for the asset
// has done, no matter succeed or failed,
//
// It is safe to delete the lease-detection blob now.

_logger.LogTrace("The lease for output path {path} under {container} is released.",
await lockBlob.DeleteAsync(DeleteSnapshotsOption.IncludeSnapshots,
new BlobRequestConditions() { LeaseId = _leaseId },
cancellationToken);

_logger.LogTrace("The lease-detect blob for output path {path} under {container} is deleted.",
outputPath,
containerName);
}
Expand Down

0 comments on commit 79363b8

Please sign in to comment.