Repository navigation
Fix Azure blob download close errors - #2200
Merged
Merged
Conversation
A failed copy was reported as success when the file close succeeded, so a partial object was archived. The download body was also left open on every fetch. Close the body on every return and keep the copy error. Match the GCP FGetObject close pattern. Assisted-by: Grok/grok-4.7 Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
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.
Azure Bucket downloads could publish a partial object and leak the HTTP connection.
BlobClient.FGetObjectcopies theDownloadStreambody into a local file. On a short read,io.Copyfails and the code assignederr = f.Close(). A successful close replaced the copy error with nil, so the reconciler archived the partial object. The response body was also never closed.GCP
FGetObjectalready closes its reader and keeps the copy error. This matches that pattern. The download body is closed on every return, and a failed copy is returned even when closing the file succeeds. A close error after a failed copy is logged. The writable file is closed with a checked error rather thandefer, so a flush failure on the success path is not dropped.The Azure client landed in #598.
DownloadStreamwithout a body close landed in #931. The GCP close fix is #2053.Tests
These tests failed on the previous code:
TestBlobClient_FGetObject_CopyErrorexpected an error and got nil.TestBlobClient_FGetObject_ClosesResponseBodyleft the response body open.That package passes after the fix.
gofmt -lon the changed files is empty, andgo vet ./internal/bucket/azure/is clean.