[Bug]: Retry on network errors before giving up
I have done the following
- [x] I have searched the existing issues
- [x] If possible, I've reproduced the issue using the 'main' branch of this project
Steps to reproduce
- Pull a large ~30 GB image (an exact link isn't disclosed).
Problem description
This fails with:
Error: StreamClosed(streamID: HTTP2StreamID(45), errorCode: HTTP2ErrorCode<0x1 ProtocolError>, location: "NIOHTTP2/HTTP2StreamChannel.swift:892")
Or just:
Error: HTTPClientError.remoteConnectionClosed
Environment
- OS: macOS
- Container: commit 6e65319
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Hi @dkovba, I looked into this. The pull fails because containerization only retries when the connection fails before the server responds. If the connection drops while a layer is downloading, the error goes straight up and the pull stops.
I have a fix: when the download drops, ask for the rest of the layer with a Range header and continue where it left off, using the existing retry settings. If the registry doesn't support ranges, it starts the layer over. I tested it with a local server that cuts the connection mid-download.
Does this sound okay? If yes, I'll open the PR in containerization.
Opened apple/containerization#949 for this.
Related: apple/containerization#1035. When a pull fails, the layers that already finished are deleted along with the ingest session, so the retry downloads them again. apple/containerization#949 resumes the layer in flight, but the finished ones are still lost if the pull ends up failing.