Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete the lease-detection blob after the migration for the asset is … #99

Merged
merged 1 commit into from
Jul 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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