Skip to content

core/unpack: ignore child mounts when detecting staged layers - #14412

Open
cvas22 wants to merge 1 commit into
containerd:mainfrom
cvas22:fix/14367-unpack-staged-child-mounts
Open

cvas22 wants to merge 1 commit into
containerd:mainfrom
cvas22:fix/14367-unpack-staged-child-mounts

Conversation

@cvas22

@cvas22 cvas22 commented Oct 17, 2026 •

Copy link
Copy Markdown

isStaged decides whether Prepare already staged a layer by checking whether the last mount returned by the snapshotter is read-only. Some snapshotters append child mounts after the rootfs mount, using mount.Target to place them on a subdirectory of the root. For example, nix-snapshotter appends a read-only bind mount for every Nix store path after the writable overlay mount.

With such snapshotters the last mount is a read-only child mount, so the unpacker wrongly treated every layer as already staged and skipped fetching and applying it. Any layer stacked on top of a nix-snapshotter layer silently disappeared from the unpacked rootfs.

Only the last mount without a Target (or with "/" as Target) describes the root, so inspect that one and skip child mounts.

Fixes #14367

This change was prepared with the help of an AI coding assistant; I have reviewed and tested it.

Copilot AI balanced review requested due to automatic review settings October 17, 2026 15:26
@github-project-automation github-project-automation Bot moved this to Needs Triage in Pull Request Review Oct 17, 2026
@cvas22 cvas22 changed the title fix(core/unpack): ignore child mounts when detecting staged layers core/unpack: ignore child mounts when detecting staged layers Oct 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused fix has relevant regression coverage and no identified blocking issues; tests were not executed.

No open issues 🎉

What changed in this PR

Fixes staged-layer detection so child mounts do not cause the unpacker to skip layers above nix-snapshotter images, addressing #14367.

Changes:

  • Inspect the last root mount, ignoring child mounts.
  • Add regression cases for child mounts, explicit root targets, and missing root mounts.
File Description
core/​unpack/​unpacker.go Restricts staged-layer detection to root mounts and updates documentation.
core/​unpack/​unpacker_test.go Adds regression coverage for mount-target handling.

Review effort: Balanced

@cvas22
cvas22 force-pushed the fix/14367-unpack-staged-child-mounts branch from 0bb97f9 to df3d89a Compare October 17, 2026 15:42
isStaged decides whether Prepare already staged a layer by checking
whether the last mount returned by the snapshotter is read-only. Some
snapshotters append child mounts after the rootfs mount, using
mount.Target to place them on a subdirectory of the root. For example,
nix-snapshotter appends a read-only bind mount for every Nix store path
after the writable overlay mount.

With such snapshotters the last mount is a read-only child mount, so the
unpacker wrongly treated every layer as already staged and skipped
fetching and applying it. Any layer stacked on top of a nix-snapshotter
layer silently disappeared from the unpacked rootfs.

Only the last mount without a Target (or with "/" as Target) describes
the root, so inspect that one and skip child mounts.

Fixes containerd#14367

Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
@cvas22
cvas22 force-pushed the fix/14367-unpack-staged-child-mounts branch from df3d89a to b7d5c09 Compare October 17, 2026 15:44

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

[nix-snapshotter] Broken containers after 257a590 (v2.4.0-beta.0)

2 participants