Skip to content

Conversation

@henry118
Copy link
Member

@henry118 henry118 commented Sep 9, 2025

Fixed an issue where pulling image fails when concurrent_layer_fetch_buffer is small.

Repro steps:

  1. Configure containerd with
[plugins]
  [plugins.'io.containerd.transfer.v1.local']
    max_concurrent_downloads = 20
    concurrent_layer_fetch_buffer = 518
  1. Pull image:
# ctr i pull docker.io/library/hello-world:latest
docker.io/library/hello world:latest            fetching image content
└──index (a0dfb02aac21)                         downloading     |++++++++++++++++++++++++++++++++++++++|        12.1 KiB/12.1 KiB
application/vnd.oci.image.index.v1+json sha256:a0dfb02aac212703bfcb339d77d47ec32c8706ff250850ecc0e19c8737b18567
Pulling from OCI Registry (docker.io/library/hello-world:latest)        elapsed: 1.6 s  total:  12.1 K  (7.5 KiB/s)
ctr: failed commit on ref "index-sha256:a0dfb02aac212703bfcb339d77d47ec32c8706ff250850ecc0e19c8737b18567": "index-sha256:a0dfb02aac212703bfcb339d77d47ec32c8706ff250850ecc0e19c8737b18567" failed size validation: 12432 != 12341: failed precondition

Here is the dump of the HTTP response, the registry did not return content-range in the response header:

Sep 09 19:01:36 ip-172-31-63-131 containerd[293664]: time="2025-09-09T19:01:36.846936961Z" level=debug msg="fetch response received" digest="sha256:a0dfb02aac212703bfcb339d77d47ec32c8706ff250850ecc0e19c8737b18567" mediatype=application/vnd.oci.image.index.v1+json response.header.connection=keep-alive response.header.content-length=12341 response.header.content-type=application/vnd.oci.image.index.v1+json response.header.date="Tue, 09 Sep 2025 19:01:36 GMT" response.header.docker-content-digest="sha256:a0dfb02aac212703bfcb339d77d47ec32c8706ff250850ecc0e19c8737b18567" response.header.docker-distribution-api-version=registry/2.0 response.header.docker-ratelimit-source=35.88.37.181 response.header.etag="\"sha256:a0dfb02aac212703bfcb339d77d47ec32c8706ff250850ecc0e19c8737b18567\"" response.header.ratelimit-limit="100;w=21600" response.header.ratelimit-remaining="70;w=21600" response.header.strict-transport-security="max-age=31536000" response.status="200 OK" size=12341 url="https://registry-1.docker.io/v2/library/hello-world/manifests/sha256:a0dfb02aac212703bfcb339d77d47ec32c8706ff250850ecc0e19c8737b18567"

Fix

The Fetcher sets the Range header if parallelism > 1 or offset > 0.

if parallelism > 1 || offset > 0 {
req.setOffset(offset)
}

But withOffsetCheck returns nil for error when offset == 0 only.

if offset == 0 {
return nil
}

This logic cannot handle the scenario when a registry ignores the range-get request for small layers. The correct logic should return errContentRangeIgnored in this case.

@henry118
Copy link
Member Author

henry118 commented Sep 9, 2025

/test pull-containerd-node-e2e

… by registry

Signed-off-by: Henry Wang <henwang@amazon.com>
@henry118
Copy link
Member Author

Kindly ping @dmcgowan @fuweid

This patch fixes a corner case of the multipart fetch. And I think it should be backported to 2.1 too.

@github-project-automation github-project-automation bot moved this from Needs Triage to Review In Progress in Pull Request Review Sep 19, 2025
@AkihiroSuda AkihiroSuda added this pull request to the merge queue Sep 19, 2025
@AkihiroSuda
Copy link
Member

/cherry-pick release/2.1

@k8s-infra-cherrypick-robot

@AkihiroSuda: once the present PR merges, I will cherry-pick it on top of release/2.1 in a new PR and assign it to you.

Details

In response to this:

/cherry-pick release/2.1

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Merged via the queue into containerd:main with commit cef8ce2 Sep 19, 2025
91 of 96 checks passed
@github-project-automation github-project-automation bot moved this from Review In Progress to Done in Pull Request Review Sep 19, 2025
@k8s-infra-cherrypick-robot

@AkihiroSuda: new pull request created: #12312

Details

In response to this:

/cherry-pick release/2.1

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@henry118 henry118 deleted the fix-range-igore branch September 19, 2025 22:41
KCSesh added a commit to KCSesh/bottlerocket-core-kit that referenced this pull request Oct 31, 2025
…quest is ignored

This patch addresses an issue where containerd was not properly returning
the errContentRangeIgnored error when range-get requests are ignored by
the registry or storage backend using the new image transfer service.

The fix ensures that the appropriate error is returned to maintain
consistent error handling behavior for range requests that cannot be
processed.

Based on upstream PR: containerd/containerd#12291

Signed-off-by: Kyle Sessions <kssessio@amazon.com>
KCSesh added a commit to KCSesh/bottlerocket-core-kit that referenced this pull request Oct 31, 2025
…quest is ignored

This patch addresses an issue where containerd was not properly returning
the errContentRangeIgnored error when range-get requests are ignored by
the registry or storage backend using the new image transfer service.

The fix ensures that the appropriate error is returned to maintain
consistent error handling behavior for range requests that cannot be
processed.

Based on upstream PR: containerd/containerd#12291

Signed-off-by: Kyle Sessions <kssessio@amazon.com>
KCSesh added a commit to KCSesh/bottlerocket-core-kit that referenced this pull request Oct 31, 2025
This patch addresses an issue where containerd was not properly returning
the errContentRangeIgnored error when range-get requests are ignored by
the registry or storage backend using the new image transfer service.

The fix ensures that the appropriate error is returned to maintain
consistent error handling behavior for range requests that cannot be
processed.

Based on upstream PR: containerd/containerd#12291

Signed-off-by: Kyle Sessions <kssessio@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants