Skip to content

engine: retry image pulls and resolves after a network error - #14978

Merged
sipsma merged 4 commits into
mainfrom
sipsma/registry-pull-retry
Nov 10, 2026
Merged

sipsma merged 4 commits into
mainfrom
sipsma/registry-pull-retry

Conversation

@sipsma

@sipsma sipsma commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Since #11856 moved image pulls onto the new resolver, a pull makes each registry request once. A network error partway through now fails the whole Container.from, where the old pull path retried. This affects anyone pulling from a registry that occasionally drops connections. In our CI it is behind every recent TestPlatform/TestWindows failure: mcr.microsoft.com resets connections now and then.

This PR retries both requests that can hit this, with BuildKit's existing retry handler, the one the pre-#11856 pull path used. It retries connection resets, EOFs, temporary network errors and 5xx responses, up to 4 attempts, waiting 1, 2 and 4 s.

  • Layer and blob downloads (Resolver.Pull): a reset partway through a layer failed with failed to copy: ... connection reset by peer. containerd's reader only reconnects after an unexpected EOF. A retried download resumes where it stopped. Three of the four recent TestWindows failures were this.
  • Resolving the manifest (resolveRemoteRootDescriptor, which resolving an image's config, resolving its digest and pulling all go through): containerd retries some error statuses (401, 408, 429, a 5xx), but no network errors. The fourth failure was failed to do request: Head ".../manifests/ltsc2022": net/http: TLS handshake timeout.

A missing image, a refused login and other 4xx answers still fail at once. Pulls that succeed take the same path as before. A pull that keeps hitting network errors now takes up to about 7 s longer to fail.

Tests, in engine/server/resolver/pull_metadata_test.go, run by CI's test-split/test-packages:

  • A registry that sends half a layer, resets the connection, then serves the resumed range request. Without the fix the test fails with CI's exact error.
  • A TLS registry that never answers the first handshake. Without the fix the test fails with CI's exact TLS handshake timeout error.
  • A missing manifest gets exactly one request, with no retry.

@sipsma
sipsma force-pushed the sipsma/registry-pull-retry branch 4 times, most recently from 8c9d803 to eb99d0a Compare November 4, 2026 21:09
@sipsma
sipsma force-pushed the sipsma/registry-pull-retry branch from eb99d0a to 8b16048 Compare November 6, 2026 20:07
Pulling an image fetched each blob once. When the registry reset the
connection partway through a layer, the pull failed with "failed to
copy: ... connection reset by peer"; containerd's reader only reconnects
after an unexpected EOF. mcr.microsoft.com does this now and then, which
fails TestPlatform/TestWindows.

The pull path that #11856 replaced wrapped this handler in BuildKit's
retry handler, which retries resets, EOFs, temporary network errors and
5xx responses with backoff. Wrap the new one the same way.

Signed-off-by: Erik Sipsma <[email protected]>
Resolving an image sent its manifest request once. When the TLS
handshake with the registry timed out, Container.from failed with
"failed to do request: Head ...: net/http: TLS handshake timeout".
containerd retries a manifest request after some error statuses, but
not after a network error. mcr.microsoft.com does this now and then,
which fails TestPlatform/TestWindows.

Retry the resolve with the same retry handler as a blob fetch: network
errors, resets, EOFs and 5xx responses are retried with backoff, while
a missing image or a refused login still fails at once. This covers
resolving an image's config, its digest, and pulling it.

Signed-off-by: Erik Sipsma <[email protected]>
staticcheck's ST1016 wants every method of a type to use the same
receiver name. The test registry's handler names it registry, since r
is its request, so manifestRequests does too.

Signed-off-by: Erik Sipsma <[email protected]>
@sipsma
sipsma force-pushed the sipsma/registry-pull-retry branch 2 times, most recently from e531358 to 91a4556 Compare November 10, 2026 01:01
@sipsma
sipsma merged commit c03e197 into main Nov 10, 2026
97 checks passed
@sipsma
sipsma deleted the sipsma/registry-pull-retry branch November 10, 2026 01:25
sipsma added a commit that referenced this pull request Nov 17, 2026
…error

#14978 retried resolving an image's root and fetching its layers after a
network error, but resolving then reads the platform manifest and the
image config from the registry without a retry. On mcr.microsoft.com a
reset on the config blob still failed TestWindows: "failed to copy:
httpReadSeeker: failed open: ... write: connection reset by peer".

Retry those reads as a pull's blob fetches are: the metadata fetch every
resolve and pull runs first, and the reads a force pull makes straight
from the registry.

Signed-off-by: Erik Sipsma <[email protected]>
sipsma added a commit that referenced this pull request Nov 17, 2026
…error

#14978 retried resolving an image's root and fetching its layers after a
network error, but resolving then reads the platform manifest and the
image config from the registry without a retry. On mcr.microsoft.com a
reset on the config blob still failed TestWindows: "failed to copy:
httpReadSeeker: failed open: ... write: connection reset by peer".

Retry those reads as a pull's blob fetches are: the metadata fetch every
resolve and pull runs first, and the reads a force pull makes straight
from the registry.

Signed-off-by: Erik Sipsma <[email protected]>
sipsma added a commit that referenced this pull request Nov 20, 2026
…error

#14978 retried resolving an image's root and fetching its layers after a
network error, but resolving then reads the platform manifest and the
image config from the registry without a retry. On mcr.microsoft.com a
reset on the config blob still failed TestWindows: "failed to copy:
httpReadSeeker: failed open: ... write: connection reset by peer".

Retry those reads as a pull's blob fetches are: the metadata fetch every
resolve and pull runs first, and the reads a force pull makes straight
from the registry.

Signed-off-by: Erik Sipsma <[email protected]>
sipsma added a commit that referenced this pull request Nov 20, 2026
…error

#14978 retried resolving an image's root and fetching its layers after a
network error, but resolving then reads the platform manifest and the
image config from the registry without a retry. On mcr.microsoft.com a
reset on the config blob still failed TestWindows: "failed to copy:
httpReadSeeker: failed open: ... write: connection reset by peer".

Retry those reads as a pull's blob fetches are: the metadata fetch every
resolve and pull runs first, and the reads a force pull makes straight
from the registry.

Signed-off-by: Erik Sipsma <[email protected]>
sipsma added a commit that referenced this pull request Nov 21, 2026
…error

#14978 retried resolving an image's root and fetching its layers after a
network error, but resolving then reads the platform manifest and the
image config from the registry without a retry. On mcr.microsoft.com a
reset on the config blob still failed TestWindows: "failed to copy:
httpReadSeeker: failed open: ... write: connection reset by peer".

Retry those reads as a pull's blob fetches are: the metadata fetch every
resolve and pull runs first, and the reads a force pull makes straight
from the registry.

Signed-off-by: Erik Sipsma <[email protected]>
sipsma added a commit that referenced this pull request Nov 21, 2026
…error

#14978 retried resolving an image's root and fetching its layers after a
network error, but resolving then reads the platform manifest and the
image config from the registry without a retry. On mcr.microsoft.com a
reset on the config blob still failed TestWindows: "failed to copy:
httpReadSeeker: failed open: ... write: connection reset by peer".

Retry those reads as a pull's blob fetches are: the metadata fetch every
resolve and pull runs first, and the reads a force pull makes straight
from the registry.

Signed-off-by: Erik Sipsma <[email protected]>
sipsma added a commit that referenced this pull request Nov 25, 2026
…error

#14978 retried resolving an image's root and fetching its layers after a
network error, but resolving then reads the platform manifest and the
image config from the registry without a retry. On mcr.microsoft.com a
reset on the config blob still failed TestWindows: "failed to copy:
httpReadSeeker: failed open: ... write: connection reset by peer".

Retry those reads as a pull's blob fetches are: the metadata fetch every
resolve and pull runs first, and the reads a force pull makes straight
from the registry.

Signed-off-by: Erik Sipsma <[email protected]>
sipsma added a commit that referenced this pull request Nov 25, 2026
…error

#14978 retried resolving an image's root and fetching its layers after a
network error, but resolving then reads the platform manifest and the
image config from the registry without a retry. On mcr.microsoft.com a
reset on the config blob still failed TestWindows: "failed to copy:
httpReadSeeker: failed open: ... write: connection reset by peer".

Retry those reads as a pull's blob fetches are: the metadata fetch every
resolve and pull runs first, and the reads a force pull makes straight
from the registry.

Signed-off-by: Erik Sipsma <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants