Repository navigation
daemon/containerd: Keep lazy pulls lazy for remote snapshotters - #53877
Conversation
Pulls always fetched every layer blob, even when a remote snapshotter such as stargz prepared the layers lazily, which removed the download savings of lazy pulling. Skip fetching all layer content when pulling into a known remote snapshotter (nydus, overlaybd, soci, stargz). The "lazy-pull" feature overrides this in either direction. Lazily pulled images may lack layer blobs, so saving or pushing them can fail. Signed-off-by: Paweł Gronowski <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
The implementation matches the documented behavior and adequately tests the selection logic.
0 open findings
What changed in this PR
Adds configurable lazy pulling for the containerd image store, preserving remote snapshotter download savings while retaining complete pulls elsewhere.
Changes:
- Defaults lazy pulls for known remote snapshotters.
- Adds a reload-aware
lazy-pullfeature override. - Tests default and overridden behavior.
| File | Description |
|---|---|
daemon/daemon.go |
Supplies feature flags to the image service. |
daemon/containerd/service.go |
Adds the feature-provider interface. |
daemon/containerd/image_pull.go |
Conditionally fetches all layer content. |
daemon/containerd/image_pull_test.go |
Tests lazy-pull selection. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Docs follow up: docker/docs#26307 |
| } | ||
|
|
||
| var knownRemoteSnapshotters = map[string]struct{}{ | ||
| "nydus": {}, |
There was a problem hiding this comment.
We should look if the snapshotter itself could somehow advertise this (not for this PR); I was wondering if there already was something like that.
| type featuresProvider interface { | ||
| // Features returns the current feature flags, which can change when the | ||
| // daemon configuration is reloaded. | ||
| Features() map[string]bool |
There was a problem hiding this comment.
Do we need synchronization around this, or good as is?
We could change it for the function to take the name of the feature looked for
There was a problem hiding this comment.
Oh, never mind; this is something we already had, just an interface
There was a problem hiding this comment.
No need as it's not mutated after it's set.
And reload doesn't mutate the live map either. The config is deep copied as a whole and then replaced and published as new.
(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]>
Summary
Pulls always fetched every layer blob, even when a remote snapshotter such as stargz prepared the layers lazily, which removed the download savings of lazy pulling.
Skip fetching all layer content when pulling into a known remote snapshotter (nydus, overlaybd, soci, stargz). The "lazy-pull" feature overrides this in either direction.
Lazily pulled images may lack layer blobs, so saving or pushing them can fail.
Note, this effectively unfixes #53864 for remote snapshotters - however, I considerer this an expected trade-off of lazy pulling for now.
Release notes (optional)
A picture of a cute animal (not mandatory but encouraged)