Support EROFS snapshotter/differ auto-selection for transfer service pull#12784
Support EROFS snapshotter/differ auto-selection for transfer service pull#12784hsiangkao wants to merge 3 commits intocontainerd:mainfrom
Conversation
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]>
Signed-off-by: Gao Xiang <[email protected]>
|
@dmcgowan does this idea sound good in general? |
| for _, l := range up.LayerTypes { | ||
| // If the bottom layer type matches the exact unpack configuration | ||
| if layers[0].MediaType == l { | ||
| unpack = up | ||
| break outer | ||
| } | ||
| } |
There was a problem hiding this comment.
you can use slices.Contains(up.LayerTypes, layers[0].MediaType). That should simplify the code
https://pkg.go.dev/slices#Contains
| } | ||
|
|
||
| if unpack == nil && len(candidates) > 0 { | ||
| unpack = candidates[0] |
There was a problem hiding this comment.
use a pointer to keep the first platform-only match should be enough?
There was a problem hiding this comment.
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 { |
|
Feel free to close this if it is replaced by the other PR. Removed from 2.3 milestone for now. |
|
yes, it can be closed. |

It integrates a default alternative unpack configration
So that erofs image can be pull with erofs snapshotter/differ properly if
--snapshotteris not given.e.g.

ctr i pull quay.io/chengyuzhu6/ubuntu:20.04-erofsCc @dmcgowan @fuweid @ChengyuZhu6 @djdongjin @cpuguy83