-
Notifications
You must be signed in to change notification settings - Fork 382
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
Fixes to storage’s GetBlob
#2394
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, because I got tripped by these while reading the code in the context of containers/podman#22575
@@ -107,12 +107,11 @@ func (s *storageImageSource) Close() error { | |||
// GetBlob returns a stream for the specified blob, and the blob’s size (or -1 if unknown). | |||
// The Digest field in BlobInfo is guaranteed to be provided, Size may be -1 and MediaType may be optionally provided. | |||
// May update BlobInfoCache, preferably after it knows for certain that a blob truly exists at a specific location. | |||
func (s *storageImageSource) GetBlob(ctx context.Context, info types.BlobInfo, cache types.BlobInfoCache) (rc io.ReadCloser, n int64, err error) { | |||
func (s *storageImageSource) GetBlob(ctx context.Context, info types.BlobInfo, cache types.BlobInfoCache) (io.ReadCloser, int64, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A combination of several deferred calls, and a return value that's a direct function call, which itself takes an unnamed function, makes these named return values treacherously confusing. :)
@@ -177,7 +176,7 @@ func (s *storageImageSource) GetBlob(ctx context.Context, info types.BlobInfo, c | |||
// On Unix and modern Windows (2022 at least) we can eagerly unlink the file to ensure it's automatically | |||
// cleaned up on process termination (or if the caller forgets to invoke Close()) | |||
// On older versions of Windows we will have to fallback to relying on the caller to invoke Close() | |||
if err := os.Remove(tmpFile.Name()); err != nil { | |||
if err := os.Remove(tmpFile.Name()); err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had found myself scratching my head over this logic too but had set it aside because it didn't seem directly relevant to the issue at hand.
6883af1
to
a37e4f7
Compare
LGTM |
They get horribly confusing, especially here where we use "rc" for two completely different purposes: containers/podman#22575 (comment) Should not change behavior. Signed-off-by: Miloslav Trmač <[email protected]>
Try unlinking it when we are done using if we _don't_ succeed unlinking it first, not if we _do succeed_. Signed-off-by: Miloslav Trmač <[email protected]>
@giuseppe @mheon @debarshiray PTAL |
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
I already did. I couldn't spot any further changes after the initial version. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
… tangentially related to containers/podman#22575 :