Skip to content

snapshots/erofs: advertise the erofs OS feature from the snapshotter plugin - #14012

Merged
fuweid merged 2 commits into
containerd:mainfrom
crunchloop:erofs-snapshotter-os-feature
Aug 28, 2026
Merged

fuweid merged 2 commits into
containerd:mainfrom
crunchloop:erofs-snapshotter-os-feature

Conversation

@bilby91

@bilby91 bilby91 commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The erofs converter stamps os.features=["erofs"] into the image configs it produces, but the erofs snapshotter plugin never advertises a platform carrying that feature. The client-side snapshotter support check (checkSnapshotterSupport in client/image.go, reached from image.Unpack) matches the config platform against the platforms the snapshotter plugin declares, so unpacking through the Go client is refused for exactly the images the converter produces:

snapshotter erofs does not support platform {arm64 linux  [erofs] } for image sha256:...

Note the check runs unconditionally whenever the config carries os.features, regardless of CheckPlatformSupported. The current workaround is to strip os.features from the config before publishing native erofs images, which discards the marker that lets the transfer service select the erofs unpack configuration in the first place.

The fix is to advertise a second platform with OSFeatures: ["erofs"] from the snapshotter plugin — the same advertisement the erofs differ plugin (plugins/diff/erofs/plugin/plugin.go) and the transfer service's default unpack configuration (plugins/transfer/plugin_defaults_linux.go) already make.

Commits

Per @hsiangkao's review, this carries @dmcgowan's existing fix rather than a parallel implementation of it, split so the fix itself is a self-contained backport candidate for release/2.3:

  1. erofs: advertise the erofs OS feature platform from the snapshotter — @dmcgowan's 954bd7d, carried verbatim. This is the whole fix and stands alone.

  2. snapshots/erofs: pin the erofs OS feature platform to Linux, with a test — a follow-up, and a no-op on Linux. The advertisement in (1) builds the feature-bearing platform from platforms.DefaultSpec(), so on a non-Linux host the snapshotter advertises <host>(+erofs) — a platform it cannot serve, since the non-Linux snapshotter returns ErrNotImplemented for conversion (plugins/snapshots/erofs/erofs_other.go) and the differ scopes both of its advertised platforms to linux. Advertising it only lets checkSnapshotterSupport accept a config that then fails during unpack. This pins the feature-bearing platform to Linux the way the differ does, leaves the plain default platform untouched, and moves the advertised set into snapshotterPlatforms() so a test can assert that a matcher built the way the client builds it (platforms.Any over the introspected plugin platforms) matches both the default platform and the converter-stamped platform.

Drop (2) if you would rather keep the fix byte-identical to Derek's; it changes nothing on Linux.

Reproduction

Verified stock vs. patched daemon (repro run at fd399bd7, since rebased), with the diff service configured with default = ["erofs", "walking"]:

$ ctr image pull docker.io/library/busybox:latest
$ ctr image convert --erofs raw docker.io/library/busybox:latest docker.io/library/busybox:erofs

# stock daemon:
$ ctr image mount --snapshotter erofs --platform 'linux(+erofs)/arm64' docker.io/library/busybox:erofs /tmp/m
ctr: error unpacking image: snapshotter erofs does not support platform {arm64 linux  [erofs] } for image sha256:e4794331...

# patched daemon: unpack succeeds and the image mounts
$ ctr image mount --snapshotter erofs --platform 'linux(+erofs)/arm64' docker.io/library/busybox:erofs /tmp/m
sha256:3fa90a69...
$ ls /tmp/m
bin  dev  etc  home  lib  lib64  root  tmp  usr  var

(The explicit --platform 'linux(+erofs)/arm64' is needed because the default platform matcher only matches a manifest whose os.features are a subset of the matcher's — a stamped manifest is otherwise not selected at all.)

Also carried in production on top of v2.3.4: native erofs images produced by the converter unpack through the erofs snapshotter without stripping os.features.


Commit (2) and the test were developed with AI assistance (Claude); they have been reviewed, tested, and are submitted under the DCO by the human author. Commit (1) is @dmcgowan's work, carried unmodified.

Copilot AI lite review requested due to automatic review settings August 22, 2026 15:28
@github-project-automation github-project-automation Bot moved this to Needs Triage in Pull Request Review Aug 22, 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.

Pull request overview

This pull request enables client-side unpacking of native EROFS images by advertising the erofs OS feature.

Changes:

  • Adds an erofs feature platform to the snapshotter.
  • Aligns snapshotter capabilities with EROFS tooling.
Suppressed comments (1)

plugins/snapshots/erofs/plugin/plugin.go:86

  • This registration is built and imported on non-Linux targets as well (cmd/containerd/builtins/builtins_unix.go:1-25), but erofsPlatform := platforms.DefaultSpec() therefore advertises darwin/freebsd/solaris with the erofs feature. The non-Linux snapshotter implementation cannot unpack layers (plugins/snapshots/erofs/erofs_other.go:44-46), so the client support check can accept an EROFS-featured image and fail only during unpack. As in the EROFS differ registration, pin this advertised feature platform to Linux.
			erofsPlatform := platforms.DefaultSpec()
			erofsPlatform.OSFeatures = []string{"erofs"}

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

@bilby91
bilby91 force-pushed the erofs-snapshotter-os-feature branch from 84d0c39 to 260b345 Compare August 22, 2026 15:35
Copilot AI review requested due to automatic review settings August 22, 2026 15:35
@kubernetes-prow kubernetes-prow Bot added size/M and removed size/XS labels Aug 22, 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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Copilot AI review requested due to automatic review settings August 22, 2026 15:48
@bilby91
bilby91 force-pushed the erofs-snapshotter-os-feature branch from 260b345 to b231ada Compare August 22, 2026 15:49

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (2)

plugins/snapshots/erofs/plugin/plugin.go:82

  • The erofs converter preserves any existing OSFeatures and then appends erofs (core/images/converter/erofs/erofs.go:240-243), so a converted image can carry features such as ["erofs", "foo"]. platforms.Any requires the image features to be a subset of an advertised platform's features, and this entry advertises only ["erofs"]; those converted images will still be rejected by checkSnapshotterSupport. Please resolve the converter/support contract so retained features are either supported by the advertised platform or not retained when stamping the native EROFS config.
	erofsPlatform.OSFeatures = []string{"erofs"}

plugins/snapshots/erofs/plugin/plugin.go:82

  • This helper is also compiled and registered on the non-Linux Unix builds (cmd/containerd/builtins/builtins_unix.go), but the only EROFS mount handler is Linux-only (plugins/mount/erofs/plugin_linux.go). As a result, a Darwin/FreeBSD/Solaris daemon will now advertise Linux+erofs, so the client-side support check accepts a native EROFS image and the later mount fails because no handler can mount Type: "erofs". Please gate this additional platform on the Linux implementation/mount handler being available.
	erofsPlatform.OS = "linux"
	erofsPlatform.OSFeatures = []string{"erofs"}

@bilby91
bilby91 force-pushed the erofs-snapshotter-os-feature branch 2 times, most recently from e44bf8b to 53e9471 Compare August 22, 2026 21:08
@hsiangkao

Copy link
Copy Markdown
Member

FYI, derek (@dmcgowan) has a similar commit
dmcgowan@954bd7d
Anyway, I wish it could be a seperate fix in order to backport to v2.3, but could you use the derek's approach in addition to your new test?

From 954bd7dde0465dae2915dd107776a934392dd5e9 Mon Sep 17 00:00:00 2001
From: Derek McGowan <[email protected]>
Date: Sat, 15 Aug 2026 11:05:02 -0700
Subject: [PATCH] erofs: advertise the erofs OS feature platform from the
 snapshotter

Advertise a second platform - the default platform spec with OSFeatures
["erofs"] - from the EROFS snapshotter plugin, alongside the plain
default platform it already advertised. This mirrors what the EROFS
differ plugin already advertises.

This is required by client.Image.Unpack's checkSnapshotterSupport, which
rejects unpacking an image whose config declares os.features onto a
snapshotter that doesn't advertise a matching platform: without this,
pulling and unpacking an EROFS image layer format specification image
(https://github.com/erofs/erofs-image-spec) - which requires "erofs" in
os.features - with the erofs snapshotter would fail that check.

Signed-off-by: Derek McGowan <[email protected]>
---
 plugins/snapshots/erofs/plugin/plugin.go | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/plugins/snapshots/erofs/plugin/plugin.go b/plugins/snapshots/erofs/plugin/plugin.go
index 008ddbd472d15..5f7fe4a0747c9 100644
--- a/plugins/snapshots/erofs/plugin/plugin.go
+++ b/plugins/snapshots/erofs/plugin/plugin.go
@@ -75,7 +75,15 @@ func init() {
 		ID:     "erofs",
 		Config: &Config{},
 		InitFn: func(ic *plugin.InitContext) (any, error) {
-			ic.Meta.Platforms = append(ic.Meta.Platforms, platforms.DefaultSpec())
+			p := platforms.DefaultSpec()
+			ic.Meta.Platforms = append(ic.Meta.Platforms, p)
+			// Also advertise the "erofs" OS feature platform (see the EROFS
+			// image layer format specification,
+			// https://github.com/erofs/erofs-image-spec) so that clients
+			// pulling with --snapshotter erofs prefer the native EROFS image
+			// variant when one is available in a multi-platform index.
+			p.OSFeatures = []string{"erofs"}
+			ic.Meta.Platforms = append(ic.Meta.Platforms, p)
 
 			config, ok := ic.Config.(*Config)
 			if !ok {

@hsiangkao
hsiangkao requested a review from dmcgowan August 23, 2026 14:54
Advertise a second platform - the default platform spec with OSFeatures
["erofs"] - from the EROFS snapshotter plugin, alongside the plain
default platform it already advertised. This mirrors what the EROFS
differ plugin already advertises.

This is required by client.Image.Unpack's checkSnapshotterSupport, which
rejects unpacking an image whose config declares os.features onto a
snapshotter that doesn't advertise a matching platform: without this,
pulling and unpacking an EROFS image layer format specification image
(https://github.com/erofs/erofs-image-spec) - which requires "erofs" in
os.features - with the erofs snapshotter would fail that check.

Signed-off-by: Derek McGowan <[email protected]>
Signed-off-by: Martín Fernández <[email protected]>
Copilot AI review requested due to automatic review settings August 23, 2026 23:34
@bilby91
bilby91 force-pushed the erofs-snapshotter-os-feature branch from 53e9471 to eeff269 Compare August 23, 2026 23:34

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (1)

plugins/snapshots/erofs/plugin/plugin.go:88

  • This helper is compiled on non-Linux targets too, so it still advertises linux/<arch>(+erofs) there. The non-Linux snapshotter's convertDirToErofs returns ErrNotImplemented (plugins/snapshots/erofs/erofs_other.go:44-46), and the EROFS mount plugin is Linux-only; nevertheless checkSnapshotterSupport will accept a stamped Linux config before unpack fails. Only add the feature-bearing platform when the default platform's OS is Linux, and make the test expect it to be absent otherwise.
	return []ocispec.Platform{platforms.DefaultSpec(), erofsPlatform}

@bilby91

bilby91 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

@hsiangkao Thanks, I didn't know about Derek's commit. I've dropped my version and carried his verbatim as the first commit, so it stays a standalone fix you can backport to 2.3.

// config that fails later during unpack.
func snapshotterPlatforms() []ocispec.Platform {
erofsPlatform := platforms.DefaultSpec()
erofsPlatform.OS = "linux"

@hsiangkao hsiangkao Aug 24, 2026 •

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.

erofs actually is an package format (like an advanced tar or zip), it should be os-independent (although only the linux kernel can currently parse it for now.), so I think erofs doesn't need to be tied to linux.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, that distinction makes sense. I conflated the EROFS package-format capability with the current host’s ability to mount it. I’ll drop the Linux override and update the test to use platforms.DefaultSpec() plus the erofs feature, preserving Derek’s behavior. The first commit will remain unchanged and independently backportable.

@hsiangkao hsiangkao 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.

other than the comment I mentioned above, I'm not sure if containerd allows claude as the committer (your Co-authored-by is already enough.)

@bilby91
bilby91 force-pushed the erofs-snapshotter-os-feature branch from eeff269 to d815665 Compare August 27, 2026 18:01
Copilot AI review requested due to automatic review settings August 27, 2026 18:01

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

plugins/snapshots/erofs/plugin/plugin.go:83

  • The feature-bearing platform is derived from platforms.DefaultSpec(), so on non-Linux hosts it advertises a host OS platform with OSFeatures=["erofs"]. This is inconsistent with the EROFS differ’s registration (plugins/diff/erofs/plugin/plugin.go:69-74 pins the EROFS platforms to OS="linux") and can cause introspected snapshotter platforms to claim support for (+erofs) even though EROFS is only meaningful for Linux images/snapshotting. Build the default platform from DefaultSpec(), but build the EROFS feature-bearing platform as Linux explicitly.
	erofsPlatform := platforms.DefaultSpec()
	result := []ocispec.Platform{erofsPlatform}
	erofsPlatform.OSFeatures = []string{"erofs"}
	return append(result, erofsPlatform)
}

The preceding commit advertises the default platform with the erofs OS feature. Move construction of that platform set into snapshotterPlatforms so the client-side matching contract can be tested without changing the advertisement.

EROFS identifies the image layer package format rather than a Linux-only host capability, so the feature-bearing entry remains derived from platforms.DefaultSpec. Test that the advertised set matches both the plain default platform and the same platform carrying the erofs feature.

Assisted-by: Claude Opus 5

Signed-off-by: Martín Fernández <[email protected]>
@bilby91
bilby91 force-pushed the erofs-snapshotter-os-feature branch from d815665 to 988f113 Compare August 27, 2026 18:08
@bilby91

bilby91 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

@hsiangkao Made the code changes. Also, removed Claude as Co-Author in favor of Assisted-By

@hsiangkao
hsiangkao requested review from cpuguy83, fuweid and mxpv August 28, 2026 00:53

@hsiangkao hsiangkao 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, anyway it needs a fix and some backports

@github-project-automation github-project-automation Bot moved this from Needs Triage to Review In Progress in Pull Request Review Aug 28, 2026
@fuweid fuweid added the cherry-pick/2.3.x Change to be cherry picked to release/2.3 label Aug 28, 2026
@fuweid
fuweid added this pull request to the merge queue Aug 28, 2026
Merged via the queue into containerd:main with commit 0d96637 Aug 28, 2026
91 of 98 checks passed
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Aug 28, 2026
@hsiangkao

Copy link
Copy Markdown
Member

/cherry-pick release/2.3

@k8s-infra-cherrypick-robot

Copy link
Copy Markdown

@hsiangkao: new pull request created: #14062

Details

In response to this:

/cherry-pick release/2.3

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.

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

Labels

cherry-pick/2.3.x Change to be cherry picked to release/2.3 size/M

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants