Skip to content

[release/2.2] Unpack images with per-layer labels for runtime-specific snapshotters#12936

Merged
mxpv merged 1 commit intocontainerd:release/2.2from
fidencio:release-2.2/backport-12835
Mar 2, 2026
Merged

[release/2.2] Unpack images with per-layer labels for runtime-specific snapshotters#12936
mxpv merged 1 commit intocontainerd:release/2.2from
fidencio:release-2.2/backport-12835

Conversation

@fidencio
Copy link
Copy Markdown
Contributor

Remote/proxy snapshotters like nydus need per-layer annotations on each snapshot (cri.image-ref, cri.layer-digest, cri.manifest-digest, cri.image-layers) so they can lazily fetch content inside the guest VM. During a normal PullImage, these annotations are set by AppendInfoHandlerWrapper and flow through the core/unpack.Unpacker to each layer's Prepare/Commit call.

However, when an image is already present for one snapshotter (e.g., overlayfs) and needs to be used with a different one (e.g., nydus for Kata), no pull occurs. The image must be unpacked into the target snapshotter with the correct per-layer labels.

Replace the image.Unpack() fallback in customopts.WithNewSnapshot with unpackImage, which leverages the existing core/unpack.Unpacker and wraps the image handler with AppendInfoHandlerWrapper when snapshot annotations are enabled (!DisableSnapshotAnnotations). This reuses the same unpack machinery as PullImage, including retry handling, parallel layer support, and deduplication.

Note: this is a manual backport of PR #12835 (targeting main). On release/2.2, DisableSnapshotAnnotations lives on ImageConfig which is not embedded in criconfig.Config, so we expose it via a new DisableSnapshotAnnotations() method on the ImageService interface instead of accessing the config field directly.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Pull Request Review Feb 24, 2026
@dosubot dosubot Bot added the area/cri Container Runtime Interface (CRI) label Feb 24, 2026
@fidencio
Copy link
Copy Markdown
Contributor Author

fidencio commented Feb 24, 2026

#12835 is still pending, but let me ...
cc @fuweid @mikebrow @mxpv

…tters

Remote/proxy snapshotters like nydus need per-layer annotations on each
snapshot (cri.image-ref, cri.layer-digest, cri.manifest-digest,
cri.image-layers) so they can lazily fetch content inside the guest VM.
During a normal PullImage, these annotations are set by
AppendInfoHandlerWrapper and flow through the core/unpack.Unpacker to
each layer's Prepare/Commit call.

However, when an image is already present for one snapshotter (e.g.,
overlayfs) and needs to be used with a different one (e.g., nydus for
Kata), no pull occurs.  The image must be unpacked into the target
snapshotter with the correct per-layer labels.

Replace the image.Unpack() fallback in customopts.WithNewSnapshot with
unpackImage, which leverages the existing core/unpack.Unpacker and wraps
the image handler with AppendInfoHandlerWrapper when snapshot annotations
are enabled (!DisableSnapshotAnnotations).  This reuses the same unpack
machinery as PullImage, including retry handling, parallel layer
support, and deduplication.

Note: this is a manual backport of PR containerd#12835 (targeting main).  On
release/2.2, DisableSnapshotAnnotations lives on ImageConfig which is
not embedded in criconfig.Config, so we expose it via a new
DisableSnapshotAnnotations() method on the ImageService interface
instead of accessing the config field directly.

Signed-off-by: Fabiano Fidêncio <[email protected]>
@fidencio fidencio force-pushed the release-2.2/backport-12835 branch from 1a7fdd7 to a5f83d8 Compare February 24, 2026 22:44
@fidencio fidencio changed the title [backport][release/2.2] cri: unpack images with per-layer labels for runtime-specific snapshotters [release/2.2] cri: unpack images with per-layer labels for runtime-specific snapshotters Feb 25, 2026
@fuweid
Copy link
Copy Markdown
Member

fuweid commented Feb 26, 2026

@mxpv do we need to backport this #12849 into v2.2? If 2.2 is LTS, it could be easier to maintain such kind of backports.

@fidencio
Copy link
Copy Markdown
Contributor Author

@mxpv do we need to backport this #12849 into v2.2? If 2.2 is LTS, it could be easier to maintain such kind of backports.

I think the community is considering 2.3 as the potential LTS, but the discussion is still open in the air, @fuweid.

@mxpv
Copy link
Copy Markdown
Member

mxpv commented Feb 27, 2026

Need to clarify which release is the next LTS.
Changes in #12849 are mostly refactoring, but it does make sense to me (in case of 2.2 is LTS) to backport it to avoid conflicts when cherry-picking.

@fidencio
Copy link
Copy Markdown
Contributor Author

Looking at the most recent updates on #12830, it seems the 2.3 will be the LTS.

@fidencio
Copy link
Copy Markdown
Contributor Author

fidencio commented Mar 2, 2026

@fuweid @mikebrow @mxpv, please let me know if I should backport also #12849 and its dependencies, as that one does not apply cleanly on 2.2.

Copy link
Copy Markdown
Member

@fuweid fuweid left a comment

Choose a reason for hiding this comment

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

The change looks good to me and seems like a bug fix.

It does change the ImageService interface, but ImageService is internal, so it shouldn’t impact end users.

One downside: it could make subsequent backports more difficult (or require adjustments).

ping @containerd/reviewers @containerd/committers to review whether this change is eligible for backport.

@github-project-automation github-project-automation Bot moved this from Needs Triage to Review In Progress in Pull Request Review Mar 2, 2026
@mxpv mxpv merged commit 8b085dd into containerd:release/2.2 Mar 2, 2026
88 of 90 checks passed
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Mar 2, 2026
@samuelkarp samuelkarp changed the title [release/2.2] cri: unpack images with per-layer labels for runtime-specific snapshotters [release/2.2] Unpack images with per-layer labels for runtime-specific snapshotters Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cri Container Runtime Interface (CRI) impact/changelog size/L

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants