Repository navigation
snapshots/erofs: advertise the erofs OS feature from the snapshotter plugin - #14012
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request enables client-side unpacking of native EROFS images by advertising the erofs OS feature.
Changes:
- Adds an
erofsfeature 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), buterofsPlatform := platforms.DefaultSpec()therefore advertisesdarwin/freebsd/solariswith theerofsfeature. 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.
84d0c39 to
260b345
Compare
260b345 to
b231ada
Compare
There was a problem hiding this comment.
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
OSFeaturesand then appendserofs(core/images/converter/erofs/erofs.go:240-243), so a converted image can carry features such as["erofs", "foo"].platforms.Anyrequires 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 bycheckSnapshotterSupport. 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 mountType: "erofs". Please gate this additional platform on the Linux implementation/mount handler being available.
erofsPlatform.OS = "linux"
erofsPlatform.OSFeatures = []string{"erofs"}
e44bf8b to
53e9471
Compare
|
FYI, derek (@dmcgowan) has a similar commit 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 { |
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]>
53e9471 to
eeff269
Compare
There was a problem hiding this comment.
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'sconvertDirToErofsreturnsErrNotImplemented(plugins/snapshots/erofs/erofs_other.go:44-46), and the EROFS mount plugin is Linux-only; neverthelesscheckSnapshotterSupportwill 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}
|
@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" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.)
eeff269 to
d815665
Compare
There was a problem hiding this comment.
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]>
d815665 to
988f113
Compare
|
@hsiangkao Made the code changes. Also, removed Claude as Co-Author in favor of Assisted-By |
hsiangkao
left a comment
There was a problem hiding this comment.
LGTM, anyway it needs a fix and some backports
|
/cherry-pick release/2.3 |
|
@hsiangkao: new pull request created: #14062 DetailsIn response to this:
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. |
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 (checkSnapshotterSupportinclient/image.go, reached fromimage.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:Note the check runs unconditionally whenever the config carries
os.features, regardless ofCheckPlatformSupported. The current workaround is to stripos.featuresfrom 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:erofs: advertise the erofs OS feature platform from the snapshotter— @dmcgowan's954bd7d, carried verbatim. This is the whole fix and stands alone.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 fromplatforms.DefaultSpec(), so on a non-Linux host the snapshotter advertises<host>(+erofs)— a platform it cannot serve, since the non-Linux snapshotter returnsErrNotImplementedfor conversion (plugins/snapshots/erofs/erofs_other.go) and the differ scopes both of its advertised platforms tolinux. Advertising it only letscheckSnapshotterSupportaccept 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 intosnapshotterPlatforms()so a test can assert that a matcher built the way the client builds it (platforms.Anyover 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 withdefault = ["erofs", "walking"]:(The explicit
--platform 'linux(+erofs)/arm64'is needed because the default platform matcher only matches a manifest whoseos.featuresare 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.