Skip to content

daemon/containerd: Always fetch missing layer content - #53615

Merged
thaJeztah merged 2 commits into
moby:masterfrom
vvoland:fix-missing-content
Sep 18, 2026
Merged

thaJeztah merged 2 commits into
moby:masterfrom
vvoland:fix-missing-content

Conversation

@vvoland

@vvoland vvoland commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Enable WithUnpackFetchAllContent so pulls fetch missing layer blobs even when snapshots are already present.

This fixes incomplete images in the containerd image store when layer snapshots already exist but the blobs referenced by the pulled image are missing.

Addresses the incomplete content at pull time rather than working around it separately in listing, inspection, export, or push.

An existing snapshot does not guarantee that the corresponding distributable blob is available.
This can happen when:

  • Image content is deleted while a container keeps the unpacked snapshots alive.
  • Multiple images share the same uncompressed layers but reference differently compressed blobs.
  • An image is loaded from a graphdriver archive containing uncompressed layers, then pulled from a registry that serves compressed layers.

Release notes (optional)

containerd image store: Fix pulls skipping required layer blobs when unpacked layers already exist, leaving images runnable but incomplete for export or push.

A picture of a cute animal (not mandatory but encouraged)

@vvoland vvoland added this to the 29.9.0 milestone Sep 10, 2026
@vvoland vvoland self-assigned this Sep 10, 2026
@vvoland vvoland added area/images Image Service kind/bugfix PR's that fix bugs containerd-integration Issues and PRs related to containerd integration labels Sep 10, 2026
@vvoland vvoland added impact/changelog and removed area/daemon Core Engine labels Sep 10, 2026
@vvoland
vvoland force-pushed the fix-missing-content branch from 5db73bc to d3ba3d4 Compare September 10, 2026 15:49
@github-actions github-actions Bot added the area/daemon Core Engine label Sep 10, 2026
@vvoland
vvoland force-pushed the fix-missing-content branch from d3ba3d4 to 529fd1d Compare September 10, 2026 15:50
Create a container to retain an image's unpacked snapshots, remove the
image by tag and ID, and pull it again from a local registry. Verify
that its layer blobs were garbage collected before the second pull so
retained content cannot hide a skipped download.

Check saved layer contents against the original fixture before
deletion and after re-pulling. A successful save response alone is
insufficient because the exporter skips missing content.

The regression test currently fails after the second pull because the
saved archive is missing layer blobs, reproducing the existing
containerd image-store bug. No production behavior is changed.

Signed-off-by: Paweł Gronowski <[email protected]>
Enable `WithUnpackFetchAllContent` so pulls fetch missing layer blobs
even when snapshots are already present.

This fixes incomplete images in the containerd image store when layer
snapshots already exist but the blobs referenced by the pulled image are
missing.

Addresses the incomplete content at pull time rather than working around
it separately in listing, inspection, export, or push.

An existing snapshot does not guarantee that the corresponding
distributable blob is available. This can happen when:
- Image content is deleted while a container keeps the unpacked
  snapshots alive.
- Two images share the same uncompressed layers but reference
  differently compressed blobs.
- An image is loaded from a graphdriver archive containing uncompressed
  layers, then pulled from a registry that serves compressed layers.

Signed-off-by: Paweł Gronowski <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused implementation uses containerd’s intended option and includes targeted regression coverage.

Pull request overview

Ensures containerd-backed pulls fetch missing layer blobs even when snapshots already exist.

Changes:

  • Enable WithUnpackFetchAllContent during pulls.
  • Add regression coverage validating saved layer completeness after content removal.
File summaries
File Description
integration/image/pull_test.go Tests repulling and exporting layers retained only as snapshots.
daemon/containerd/image_pull.go Configures unpacking to fetch all missing content.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@vvoland
vvoland marked this pull request as ready for review September 18, 2026 11:43

@thaJeztah thaJeztah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I'll open a follow-up with my suggestion.

Comment on lines +85 to +87
defer rdr.Close()
assert.NilError(t, jsonmessage.DisplayStream(rdr, io.Discard))
assert.NilError(t, rdr.Close())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can probably be just;

Suggested change
defer rdr.Close()
assert.NilError(t, jsonmessage.DisplayStream(rdr, io.Discard))
assert.NilError(t, rdr.Close())
assert.NilError(t, rdr.Wait(ctx))

Comment on lines +115 to +117
defer rdr.Close()
assert.NilError(t, jsonmessage.DisplayStream(rdr, io.Discard))
assert.NilError(t, rdr.Close())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here;

Suggested change
defer rdr.Close()
assert.NilError(t, jsonmessage.DisplayStream(rdr, io.Discard))
assert.NilError(t, rdr.Close())
assert.NilError(t, rdr.Wait(ctx))

@vvoland vvoland linked an issue Nov 16, 2026 that may be closed by this pull request
malon64 pushed a commit to OpenLakeForge/openlakeforge that referenced this pull request Nov 18, 2026
Run 44317713806 showed the real cause: right after `docker pull` of the
kube-state-metrics pin, Docker 29.4.2 on the runner reported the image
"does not provide the specified platform (linux/amd64)". Its first three
layer diff IDs are those of the cert-manager images, which are prefetched
first, under other blob digests (same distroless base, recompressed).
Docker before 29.9 with the containerd image store skips a layer's blob
on pull when a snapshot with that diff ID already exists, and its
exporter then leaves the blob out (fixed in 29.9.0, moby/moby#53615). The
first run's archive therefore lacked the amd64 content, and `ctr import`
failed on its config.

No reference or save flag repairs that store, so drop the platform-scoped
save and the API-version gate from the two earlier commits and go back to
main's pull and save. When `docker save` or a node's `ctr import` fails,
the node pulls the pinned reference with `crictl pull`, and containerd
verifies the digest. If the node cannot reach the registry either (#757),
the error says that Docker 29.9 or later archives the image.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UVCVTkEzR8Ci9GVkiY8j2j
ipmb added a commit to apppackio/apppack-codebuild-image that referenced this pull request Nov 18, 2026
The runner's daemon is Docker 29.4.2 with the containerd image store.
A pull there can leave an image missing the compressed blobs for layers
already unpacked on disk (moby/moby#49784, from containerd/containerd#8973),
so the image runs but cannot be exported.

pack build hits this: a builder carries the run image's base layers, and
heroku/builder's layers were re-gzipped at some point, so builder and run
image share diffIDs but reference different blobs. Pack pulls the builder
first, leaving the run image incomplete. Exporting to the daemon then has
to docker save the run image, which fails with

    failed to fetch base layers: open /tmp/imgutil.local.image.*/blobs/sha256/...

That is buildpacks/pack#2747. It is why integration-heroku24 started
failing while the builder:22 jobs stayed green: those two images do not
share layers the same way.

Fixed in moby/moby#53615, first released in Docker 29.9.0, which the
runner images do not have yet (actions/runner-images#15330). So start a
29.10.0 daemon instead of using the runner's.

The action inherits the runner's /etc/docker/daemon.json, so the image
store is unchanged and the Docker version is the only variable. Its
daemon listens on its own socket rather than /var/run/docker.sock, so
the bind mount follows DOCKER_HOST.

Co-Authored-By: Claude Opus 5 <[email protected]>
ipmb added a commit to apppackio/apppack-codebuild-image that referenced this pull request Nov 18, 2026
The runner's daemon is Docker 29.4.2 with the containerd image store.
A pull there can leave an image missing the compressed blobs for layers
already unpacked on disk (moby/moby#49784, from containerd/containerd#8973),
so the image runs but cannot be exported.

pack build hits this: a builder carries the run image's base layers, and
heroku/builder's layers were re-gzipped at some point, so builder and run
image share diffIDs but reference different blobs. Pack pulls the builder
first, leaving the run image incomplete. Exporting to the daemon then has
to docker save the run image, which fails with

    failed to fetch base layers: open /tmp/imgutil.local.image.*/blobs/sha256/...

That is buildpacks/pack#2747. It is why integration-heroku24 started
failing while the builder:22 jobs stayed green: those two images do not
share layers the same way.

Fixed in moby/moby#53615, first released in Docker 29.9.0, which the
runner images do not have yet (actions/runner-images#15330). So start a
29.10.0 daemon instead of using the runner's.

The action inherits the runner's /etc/docker/daemon.json, so the image
store is unchanged and the Docker version is the only variable. Its
daemon listens on its own socket rather than /var/run/docker.sock, so
the bind mount follows DOCKER_HOST.

Co-authored-by: Claude Opus 5 <[email protected]>
ethanjli added a commit to openUC2/os-rpi that referenced this pull request Nov 19, 2026
(This PR completely rewritten by Ethan)

## Expanded description PR

This PR works around a non-version-controlled regression in the size of
the OS image which was introduced by Docker Engine 29.9.0, resulting in
images being ~8.5 GB with moderate compression. Specifically, this PR
runs `docker pull` in lazy-pull mode (described further below). The
result is that SD card images are now only ~3.5 GB with moderate
compression, and first boot takes a bit longer.

This PR also fixes a regression which was introduced by
00c612b, which resulted in the `pi`
user's shell being set by default to `/usr/sbin/nologin` instead of
`/usr/bin/bash` due to a behavior change in the underlying Raspberry Pi
OS.

This work is tracked on Notion at
https://app.notion.com/p/Troubleshoot-huge-regression-in-OS-image-file-size-4164e612c78a80da80f9c29455cb2e2b
.

## Bene's Original PR description

### Why

Since 2026-10-08 the `.img.xz` grew from ~5.90 GB to ~8.55 GB, also for
rebuilds of older commits.

Cause: `os-build/docker/install.sh` installs unpinned Docker. Docker
Engine 29.9.0 (released 2026-10-08, containerd 2.4.1) fixed "pulls
skipping required layer blobs when unpacked layers already exist"
(moby/moby#53615). Our build does `docker image load` from the
pre-downloaded tarballs, then `forklift stage set-next` pulls the same
images again. Up to 29.8.2 that pull skipped the blobs (1 s). From
29.9.0 it downloads all compressed layers (22 s) into containerd's
content store.

Evidence from run logs (#37624957554 small vs #38280313540 large):
- only apt diffs: docker-ce 29.8.2→29.9.0, containerd.io 2.3.6→2.4.1,
tailscale
- rootfs after PiShrink: 16.70 → 19.40 GB (+2.71 GB); compressed layers
of the 11 images: 2.68 GB
- action SHAs, base image, PiShrink version all identical

### Change

Write `/etc/docker/daemon.json` with `{"features": {"lazy-pull": true}}`
before Docker is installed. `lazy-pull` (moby/moby#53877, new in 29.9.0)
controls whether `docker pull` skips layer content the snapshotter
already provides; by default it's only on for remote snapshotters.

### To verify

- The CI artifact for this PR should be ~5.9 GB instead of ~8.55 GB.
- In the build log, the forklift re-pull of the 11 images should take ~1
s again, with no `Write failed … locked` errors.

Note: like pre-Oct-8 images, the loaded images will be "runnable but
incomplete" (no compressed blobs), so `docker save`/`docker push` of
them on a device won't work.

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Ethan Li <[email protected]>
mkumar1205-beep pushed a commit to mkumar1205-beep/openlakeforge that referenced this pull request Nov 24, 2026
…enLakeForge#21) (OpenLakeForge#1277)

* fix(local): prefetch each image for the kind nodes' platform only (OpenLakeForge#21)

Every Full local deploy on main failed in the kind prefetch once OpenLakeForge#1265
added kube-state-metrics: `ctr images import` on the worker stopped with
"content digest sha256:a635e3d8...: not found" (run 44311223915). That
digest is the config blob of the linux/amd64 manifest under the pinned
multi-arch index.

The image was saved by tag with no platform, so Docker archived the whole
index and put under it what its image store held. On the runner the
archive was written in 43 ms, against 1.2 s for Prometheus just before,
and it lacked the amd64 config the index points to.

Pull and save every image with --platform linux/<docker server arch>.
The archive is then that platform's manifest with all its blobs, and a
store missing any of them fails at `docker save` with the digest instead
of inside a node's containerd. The node still gets the image's tag and
its index digest name, so the pin the charts use resolves offline as
before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UVCVTkEzR8Ci9GVkiY8j2j

* fix(local): save for one platform only where the engine supports it (OpenLakeForge#21)

`docker save --platform` needs Docker Engine 28 (API 1.48). An older
engine passes the docker preflight and would then have failed every
fresh local deploy at its first image save. Read the server API version
and pass --platform to save only from 1.48; older engines save as
before. Pulls keep --platform, which every supported engine accepts.

Selecting the platform on `ctr import` instead would not fix the
kube-state-metrics failure: the blob missing from the archive is the
config of the node's own platform (linux/amd64).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UVCVTkEzR8Ci9GVkiY8j2j

* fix(local): let the kind node pull an image Docker cannot archive (OpenLakeForge#21)

Run 44317713806 showed the real cause: right after `docker pull` of the
kube-state-metrics pin, Docker 29.4.2 on the runner reported the image
"does not provide the specified platform (linux/amd64)". Its first three
layer diff IDs are those of the cert-manager images, which are prefetched
first, under other blob digests (same distroless base, recompressed).
Docker before 29.9 with the containerd image store skips a layer's blob
on pull when a snapshot with that diff ID already exists, and its
exporter then leaves the blob out (fixed in 29.9.0, moby/moby#53615). The
first run's archive therefore lacked the amd64 content, and `ctr import`
failed on its config.

No reference or save flag repairs that store, so drop the platform-scoped
save and the API-version gate from the two earlier commits and go back to
main's pull and save. When `docker save` or a node's `ctr import` fails,
the node pulls the pinned reference with `crictl pull`, and containerd
verifies the digest. If the node cannot reach the registry either (OpenLakeForge#757),
the error says that Docker 29.9 or later archives the image.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UVCVTkEzR8Ci9GVkiY8j2j

---------

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/daemon Core Engine area/dependencies area/images Image Service area/testing containerd-integration Issues and PRs related to containerd integration impact/changelog kind/bugfix PR's that fix bugs

Projects

None yet

3 participants