distribution: fix / improve handling of "closed pipe" and context cancellation / timeouts#49297
Merged
vvoland merged 2 commits intomoby:masterfrom Jan 22, 2025
Conversation
…en pipe The isBrokenPipe utility was added in 3d86b0c to unwrap the error returned to detect if it was a broken pipe error. `net.OpError` now implements Unwrap(), so we can simplify this check using `errors.Is`. Signed-off-by: Sebastiaan van Stijn <[email protected]>
Before this change, it would fail to detect context errors, resulting in pullEndpoints clobbering the context error and changing it into a fallback error; https://github.com/moby/moby/blob/029933578be8070181d956a825e605c904f1865b/distribution/pull.go#L114-L119 While the context cancellation would still be handled, the error returned would be wrapped, causing calling code to no longer being able to detect it as context cancellation; https://github.com/moby/moby/blob/029933578be8070181d956a825e605c904f1865b/distribution/pull.go#L125 Context cancellation are now logged as "info" in daemon-logs, as they are not an error from the daemon's perspective; Before: DEBU[2025-01-18T14:59:10.079259676Z] pulling blob "sha256:8bb55f0677778c3027fcc4253dc452bc9c22de989a696391e739fb1cdbbdb4c2" ERRO[2025-01-18T14:59:10.564076135Z] Not continuing with pull after error: context canceled After: DEBU[2025-01-18T15:09:56.743045420Z] pulling blob "sha256:8bb55f0677778c3027fcc4253dc452bc9c22de989a696391e739fb1cdbbdb4c2" INFO[2025-01-18T15:09:57.390835628Z] Not continuing with pull after error error="context canceled" This package needs a big cleanup for context- and error-handling, as it's very messy, so these changes are only a short-term workaround. Signed-off-by: Sebastiaan van Stijn <[email protected]>
07fd767 to
5277415
Compare
vvoland
approved these changes
Jan 22, 2025
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.
distribution/utils: WriteDistributionProgress simplify check for broken pipe
The isBrokenPipe utility was added in 3d86b0c
to unwrap the error returned to detect if it was a broken pipe error.
net.OpErrornow implements Unwrap(), so we can simplify this checkusing
errors.Is.distribution: continueOnError: handle context cancellation / timeout
Before this change, it would fail to detect context errors, resulting in
pullEndpoints clobbering the context error and changing it into a fallback
error;
moby/distribution/pull.go
Lines 114 to 119 in 0299335
While the context cancellation would still be handled, the error returned
would be wrapped, causing calling code to no longer being able to detect
it as context cancellation;
moby/distribution/pull.go
Line 125 in 0299335
Context cancellation are now logged as "info" in daemon-logs, as they
are not an error from the daemon's perspective;
Before:
After:
This package needs a big cleanup for context- and error-handling, as it's
very messy, so these changes are only a short-term workaround.
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)