-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Update ACR UploadBlob method to upload a blob in chunks #32059
Conversation
API change check APIView has identified API level changes in this PR and created following API reviews. |
...containerregistry/Azure.Containers.ContainerRegistry/src/Blob/ContainerRegistryBlobClient.cs
Outdated
Show resolved
Hide resolved
...containerregistry/Azure.Containers.ContainerRegistry/src/Blob/ContainerRegistryBlobClient.cs
Show resolved
Hide resolved
...containerregistry/Azure.Containers.ContainerRegistry/src/Blob/ContainerRegistryBlobClient.cs
Show resolved
Hide resolved
.../Azure.Containers.ContainerRegistry/api/Azure.Containers.ContainerRegistry.netstandard2.0.cs
Show resolved
Hide resolved
This is also a perfect client candidate for perf testing for the SDK. Refers to: sdk/containerregistry/Azure.Containers.ContainerRegistry/api/Azure.Containers.ContainerRegistry.netstandard2.0.cs:230 in 2cda954. [](commit_id = 2cda954, deletion_comment = False) |
...containerregistry/Azure.Containers.ContainerRegistry/src/Blob/ContainerRegistryBlobClient.cs
Outdated
Show resolved
Hide resolved
...containerregistry/Azure.Containers.ContainerRegistry/src/Blob/ContainerRegistryBlobClient.cs
Outdated
Show resolved
Hide resolved
sdk/containerregistry/Azure.Containers.ContainerRegistry/src/Blob/UploadBlobResult.cs
Show resolved
Hide resolved
sdk/containerregistry/Azure.Containers.ContainerRegistry/src/Blob/OciBlobDescriptor.cs
Show resolved
Hide resolved
...containerregistry/Azure.Containers.ContainerRegistry/src/Blob/ContainerRegistryBlobClient.cs
Outdated
Show resolved
Hide resolved
...containerregistry/Azure.Containers.ContainerRegistry/src/Blob/ContainerRegistryBlobClient.cs
Outdated
Show resolved
Hide resolved
...containerregistry/Azure.Containers.ContainerRegistry/src/Blob/ContainerRegistryBlobClient.cs
Outdated
Show resolved
Hide resolved
By buffering the stream, I mean reading the whole stream into a memory stream. I could see how this could cause OOM issues. But we weren't doing this in the previous implementation, so I was curious where the memory issue was actually occurring. I would imagine it is probably in the transport layer if the transport ends up attempting to send a single request. |
...containerregistry/Azure.Containers.ContainerRegistry/src/Blob/ContainerRegistryBlobClient.cs
Outdated
Show resolved
Hide resolved
...containerregistry/Azure.Containers.ContainerRegistry/src/Blob/ContainerRegistryBlobClient.cs
Show resolved
Hide resolved
I still haven't heard back from the service team on this, but looking at the information they've given us, it looks like the OOM issue they were experience was on download of a large blob. The only thing I've been able to repro on upload is the service closing the connection, presumably because we're sending too much data/data too slowly:
Uploading in smaller chunks does mitigate this. I'll update the PR description to more accurately reflect the issue as well - thanks, @JoshLove-msft! |
...containerregistry/Azure.Containers.ContainerRegistry/src/Blob/ContainerRegistryBlobClient.cs
Outdated
Show resolved
Hide resolved
...containerregistry/Azure.Containers.ContainerRegistry/src/Blob/ContainerRegistryBlobClient.cs
Outdated
Show resolved
Hide resolved
...containerregistry/Azure.Containers.ContainerRegistry/src/Blob/ContainerRegistryBlobClient.cs
Outdated
Show resolved
Hide resolved
@nisha-bhatia, I plan to re-work the implementation to possibly use ArrayPool when I implement chunked/parallel download. Thanks again for the suggestion! |
sdk/containerregistry/Azure.Containers.ContainerRegistry/src/Blob/OciBlobDescriptor.cs
Show resolved
Hide resolved
* added Size to UploadBlobResult * Add test for pull and record tests * first pass on chunked upload; plus basic large file upload test * compute digest in chunks * fix bugs * refactor and export API * re-record failing tests * add sync tests * EOD WIP * bug fix - incr chunk count * small refactor of Content-Range header * don't compute digest 2x; validate chunkLength input * refactor to not seek streams we don't own * validate digest on blob upload and add tests for blob and manifest uploads on non-seekable streams * re-record tests for new chunked-upload approach and add recordings for new tests. * fix failing tests * don't allocate a large buffer to upload a small chunk, and PR fb. * re-record failing tests * fix missed config * missed test
Fixes #32339
The current implementation of ContainerRegistryBlobClient.UploadBlob() tries to upload an artifact layer in a single chunk, and if the layer size is large, that can cause the service to close the connection during upload, and the upload to fail.
This PR reimplements
UploadBlob()
to upload the layer in chunks, and optionally allows the caller to specify the chunk size.