Skip to content

Support EROFS snapshotter/differ auto-selection for transfer service pull#12784

Closed
hsiangkao wants to merge 3 commits intocontainerd:mainfrom
erofs:erofs-layers
Closed

Support EROFS snapshotter/differ auto-selection for transfer service pull#12784
hsiangkao wants to merge 3 commits intocontainerd:mainfrom
erofs:erofs-layers

Conversation

@hsiangkao
Copy link
Copy Markdown
Member

@hsiangkao hsiangkao commented Jan 14, 2026

It integrates a default alternative unpack configration

[[plugins."io.containerd.transfer.v1.local".unpack_config]]
    platform = "linux"
    snapshotter = "erofs"
    differ = "erofs"
    layer_types = ["application/vnd.erofs.layer.v1"]

So that erofs image can be pull with erofs snapshotter/differ properly if --snapshotter is not given.

e.g.
ctr i pull quay.io/chengyuzhu6/ubuntu:20.04-erofs
image

Cc @dmcgowan @fuweid @ChengyuZhu6 @djdongjin @cpuguy83

If the given layer types are specified in a specific unpack
configuration (`unpack_config`), use it instead of other ones
supported by the platform.

Signed-off-by: Gao Xiang <[email protected]>
Considering the following configurations:

```toml
[[plugins."io.containerd.transfer.v1.local".unpack_config]]
platform = "linux"
snapshotter = "overlayfs"
```

and

```toml
[[plugins."io.containerd.transfer.v1.local".unpack_config]]
platform = "linux"
snapshotter = "erofs"
differ = "erofs"
layer_types = ["application/vnd.erofs.layer.v1"]
```

Currently getSupportedPlatform() will return the overlayfs one since it's
`defaults.DefaultSnapshotter`, but it misses `layer_types` hints, so return
all supported platforms with the default one prioritized instead.

Signed-off-by: Gao Xiang <[email protected]>
@hsiangkao
Copy link
Copy Markdown
Member Author

note that ctr run --tty --rm quay.io/chengyuzhu6/ubuntu:20.04-erofs erofs /bin/bash is still unsupported since it hasn't been converted to use transfer service.
image

@hsiangkao
Copy link
Copy Markdown
Member Author

@dmcgowan does this idea sound good in general?
since transfer service already supports multiple unpack configurations with another snapshotter, differ and layer_types, I think erofs unpack config can be specified directly even --snapshotter is not specified, so that users will have better experience for native EROFS images.

Comment thread core/unpack/unpacker.go
Comment on lines +340 to +346
for _, l := range up.LayerTypes {
// If the bottom layer type matches the exact unpack configuration
if layers[0].MediaType == l {
unpack = up
break outer
}
}
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.

you can use slices.Contains(up.LayerTypes, layers[0].MediaType). That should simplify the code

https://pkg.go.dev/slices#Contains

Comment thread core/unpack/unpacker.go
}

if unpack == nil && len(candidates) > 0 {
unpack = candidates[0]
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.

use a pointer to keep the first platform-only match should be enough?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yeah, good idea.
But the tricky part is actually getSupportedPlatforms, since the previous getSupportedPlatform has testcases I haven't updated it :(

if v, ok := mu.SnapshotterExports["enable_remote_snapshot_annotations"]; ok && v == "true" {
enableRemoteSnapshotAnnotations = true
ma := getSupportedPlatforms(ctx, u, ts.config.UnpackPlatforms)
if len(ma) > 0 {
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.

the if is redundant.

@dmcgowan dmcgowan moved this from Needs Triage to Needs Reviewers in Pull Request Review Jan 20, 2026
@dmcgowan dmcgowan added this to the 2.3 milestone Jan 20, 2026
@dmcgowan dmcgowan removed this from the 2.3 milestone Mar 25, 2026
@dmcgowan
Copy link
Copy Markdown
Member

Feel free to close this if it is replaced by the other PR. Removed from 2.3 milestone for now.

@hsiangkao
Copy link
Copy Markdown
Member Author

yes, it can be closed.

@hsiangkao hsiangkao closed this Mar 25, 2026
@github-project-automation github-project-automation Bot moved this from Needs Reviewers to Done in Pull Request Review Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/distribution Image Distribution size/L

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants