From 56a6fdbe5b70e708ab0e28713eba4687c6836a9b Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Sat, 21 Mar 2026 04:02:31 +0800 Subject: [PATCH 1/5] Update github.com/containerd/platforms to v1.0.0-rc.4 In order to support `os.features`. Signed-off-by: Gao Xiang --- go.mod | 2 +- go.sum | 4 +- .../containerd/platforms/compare.go | 82 +++++++++++++++++ .../containerd/platforms/cpuinfo_linux.go | 2 - .../containerd/platforms/cpuinfo_other.go | 1 - .../platforms/platform_windows_compat.go | 12 +++ .../containerd/platforms/platforms.go | 92 +++++++++++++++---- vendor/modules.txt | 4 +- 8 files changed, 175 insertions(+), 24 deletions(-) diff --git a/go.mod b/go.mod index fe949c77dc..ae61e00f91 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/containerd/log v0.1.0 github.com/containerd/nri v0.11.0 github.com/containerd/otelttrpc v0.1.0 - github.com/containerd/platforms v1.0.0-rc.3 + github.com/containerd/platforms v1.0.0-rc.4 github.com/containerd/plugin v1.0.0 github.com/containerd/ttrpc v1.2.8 github.com/containerd/typeurl/v2 v2.2.3 diff --git a/go.sum b/go.sum index 8974e76d59..85ab44794b 100644 --- a/go.sum +++ b/go.sum @@ -67,8 +67,8 @@ github.com/containerd/nri v0.11.0 h1:26mcQwNG58AZn0YkOrlJQ0yxQVmyZooflnVWJTqQrqQ github.com/containerd/nri v0.11.0/go.mod h1:bjGTLdUA58WgghKHg8azFMGXr05n1wDHrt3NSVBHiGI= github.com/containerd/otelttrpc v0.1.0 h1:UOX68eVTE8H/T45JveIg+I22Ev2aFj4qPITCmXsskjw= github.com/containerd/otelttrpc v0.1.0/go.mod h1:XhoA2VvaGPW1clB2ULwrBZfXVuEWuyOd2NUD1IM0yTg= -github.com/containerd/platforms v1.0.0-rc.3 h1:YdvwaHtrN6wHcGJ2mYRYP3Nso8OcysuqFe9Hxm1X/tI= -github.com/containerd/platforms v1.0.0-rc.3/go.mod h1:gw0R+alP3nFQPh1L4K9bv13fRWeeyokLGLu2fKuqI10= +github.com/containerd/platforms v1.0.0-rc.4 h1:M42JrUT4zfZTqtkUwkr0GzmUWbfyO5VO0Q5b3op97T4= +github.com/containerd/platforms v1.0.0-rc.4/go.mod h1:lKlMXyLybmBedS/JJm11uDofzI8L2v0J2ZbYvNsbq1A= github.com/containerd/plugin v1.0.0 h1:c8Kf1TNl6+e2TtMHZt+39yAPDbouRH9WAToRjex483Y= github.com/containerd/plugin v1.0.0/go.mod h1:hQfJe5nmWfImiqT1q8Si3jLv3ynMUIBB47bQ+KexvO8= github.com/containerd/ttrpc v1.2.8 h1:xbVu6D4qF2jihdh9rDVOKqUMiFBQk6YctTdo1zk087Y= diff --git a/vendor/github.com/containerd/platforms/compare.go b/vendor/github.com/containerd/platforms/compare.go index 802b860452..ea5e7aa14b 100644 --- a/vendor/github.com/containerd/platforms/compare.go +++ b/vendor/github.com/containerd/platforms/compare.go @@ -152,6 +152,88 @@ func Only(platform specs.Platform) MatchComparer { return Ordered(platformVector(Normalize(platform))...) } +// OnlyOS returns a match comparer that matches only platforms with the same +// OS, OS version, and OS features, regardless of architecture. When comparing, +// it always ranks the best architecture match highest using the default +// platform resolution logic. +func OnlyOS(platform specs.Platform) MatchComparer { + normalized := Normalize(platform) + return onlyOSComparer{ + platform: normalized, + osvM: newOSVersionMatcher(normalized), + archOrder: orderedPlatformComparer{ + matchers: []Matcher{NewMatcher(normalized)}, + }, + } +} + +func newOSVersionMatcher(platform specs.Platform) osVerMatcher { + if platform.OS == "windows" { + return &windowsVersionMatcher{ + windowsOSVersion: getWindowsOSVersion(platform.OSVersion), + } + } + return nil +} + +type onlyOSComparer struct { + platform specs.Platform + osvM osVerMatcher + archOrder orderedPlatformComparer +} + +func (c onlyOSComparer) matchOS(platform specs.Platform) bool { + normalized := Normalize(platform) + if c.platform.OS != normalized.OS { + return false + } + if c.osvM != nil { + if !c.osvM.Match(platform.OSVersion) { + return false + } + } + if len(normalized.OSFeatures) > 0 { + if len(c.platform.OSFeatures) < len(normalized.OSFeatures) { + return false + } + j := 0 + for _, feature := range normalized.OSFeatures { + found := false + for ; j < len(c.platform.OSFeatures); j++ { + if feature == c.platform.OSFeatures[j] { + found = true + j++ + break + } + if feature < c.platform.OSFeatures[j] { + return false + } + } + if !found { + return false + } + } + } + return true +} + +func (c onlyOSComparer) Match(platform specs.Platform) bool { + return c.matchOS(platform) +} + +func (c onlyOSComparer) Less(p1, p2 specs.Platform) bool { + p1m := c.matchOS(p1) + p2m := c.matchOS(p2) + if p1m && !p2m { + return true + } + if !p1m { + return false + } + // Both match — rank by architecture preference + return c.archOrder.Less(p1, p2) +} + // OnlyStrict returns a match comparer for a single platform. // // Unlike Only, OnlyStrict does not match sub platforms. diff --git a/vendor/github.com/containerd/platforms/cpuinfo_linux.go b/vendor/github.com/containerd/platforms/cpuinfo_linux.go index 98c7001f93..06da8b9612 100644 --- a/vendor/github.com/containerd/platforms/cpuinfo_linux.go +++ b/vendor/github.com/containerd/platforms/cpuinfo_linux.go @@ -45,7 +45,6 @@ func getMachineArch() (string, error) { // So we don't need to access the ARM registers to detect platform information // by ourselves. We can just parse these information from /proc/cpuinfo func getCPUInfo(pattern string) (info string, err error) { - cpuinfo, err := os.Open("/proc/cpuinfo") if err != nil { return "", err @@ -75,7 +74,6 @@ func getCPUInfo(pattern string) (info string, err error) { // getCPUVariantFromArch get CPU variant from arch through a system call func getCPUVariantFromArch(arch string) (string, error) { - var variant string arch = strings.ToLower(arch) diff --git a/vendor/github.com/containerd/platforms/cpuinfo_other.go b/vendor/github.com/containerd/platforms/cpuinfo_other.go index 5bbfef7042..b8c7a4b226 100644 --- a/vendor/github.com/containerd/platforms/cpuinfo_other.go +++ b/vendor/github.com/containerd/platforms/cpuinfo_other.go @@ -24,7 +24,6 @@ import ( ) func getCPUVariant() (string, error) { - var variant string switch runtime.GOOS { diff --git a/vendor/github.com/containerd/platforms/platform_windows_compat.go b/vendor/github.com/containerd/platforms/platform_windows_compat.go index f31ebe0c9e..ef21a29068 100644 --- a/vendor/github.com/containerd/platforms/platform_windows_compat.go +++ b/vendor/github.com/containerd/platforms/platform_windows_compat.go @@ -17,6 +17,7 @@ package platforms import ( + "slices" "strconv" "strings" @@ -162,3 +163,14 @@ func (c *windowsMatchComparer) Less(p1, p2 specs.Platform) bool { } return m1 && !m2 } + +type windowsStripFeaturesMatcher struct { + Matcher +} + +func (m windowsStripFeaturesMatcher) Match(p specs.Platform) bool { + if i := slices.Index(p.OSFeatures, "win32k"); i >= 0 { + p.OSFeatures = slices.Delete(slices.Clone(p.OSFeatures), i, i+1) + } + return m.Matcher.Match(p) +} diff --git a/vendor/github.com/containerd/platforms/platforms.go b/vendor/github.com/containerd/platforms/platforms.go index 2d9b3c204c..81d7ee3869 100644 --- a/vendor/github.com/containerd/platforms/platforms.go +++ b/vendor/github.com/containerd/platforms/platforms.go @@ -156,6 +156,11 @@ func NewMatcher(platform specs.Platform) Matcher { m.osvM = &windowsVersionMatcher{ windowsOSVersion: getWindowsOSVersion(platform.OSVersion), } + + // In prior versions, the win32k os feature was not considered for matching, + // strip out the win32k feature for comparison + var stripped Matcher = windowsStripFeaturesMatcher{m} + // In prior versions, on windows, the returned matcher implements a // MatchComprarer interface. // This preserves that behavior for backwards compatibility. @@ -165,8 +170,9 @@ func NewMatcher(platform specs.Platform) Matcher { // It was likely intended to be used in `Ordered` but it is not since // `Less` that is implemented here ends up getting masked due to wrapping. if runtime.GOOS == "windows" { - return &windowsMatchComparer{m} + return &windowsMatchComparer{stripped} } + return stripped } return m } @@ -280,13 +286,9 @@ func Parse(specifier string) (specs.Platform, error) { } p.OSVersion = osVersion if osOptions[3] != "" { - rawFeatures := strings.Split(osOptions[3][1:], "+") - p.OSFeatures = make([]string, len(rawFeatures)) - for i, f := range rawFeatures { - p.OSFeatures[i], err = decodeOSOption(f) - if err != nil { - return specs.Platform{}, fmt.Errorf("%q has an invalid OS feature %q: %w", specifier, f, err) - } + p.OSFeatures, err = parseOSFeatures(osOptions[3][1:]) + if err != nil { + return specs.Platform{}, fmt.Errorf("%q has invalid OS features: %w", specifier, err) } } } else { @@ -346,6 +348,30 @@ func Parse(specifier string) (specs.Platform, error) { return specs.Platform{}, fmt.Errorf("%q: cannot parse platform specifier: %w", specifier, errInvalidArgument) } +func parseOSFeatures(s string) ([]string, error) { + if s == "" { + return nil, nil + } + + var features []string + for raw := range strings.SplitSeq(s, "+") { + raw = strings.TrimSpace(raw) + if raw == "" { + return nil, fmt.Errorf("empty os feature: %w", errInvalidArgument) + } + feature, err := decodeOSOption(raw) + if err != nil { + return nil, fmt.Errorf("invalid os feature %q: %w", raw, err) + } + if feature == "" { + continue + } + features = append(features, feature) + } + + return features, nil +} + // MustParse is like Parses but panics if the specifier cannot be parsed. // Simplifies initialization of global variables. func MustParse(specifier string) specs.Platform { @@ -371,21 +397,55 @@ func FormatAll(platform specs.Platform) string { if platform.OS == "" { return "unknown" } + if platform.OSVersion == "" && len(platform.OSFeatures) == 0 { + return path.Join(platform.OS, platform.Architecture, platform.Variant) + } + + var b strings.Builder + b.WriteString(platform.OS) + osv := encodeOSOption(platform.OSVersion) + formatted := formatOSFeatures(platform.OSFeatures) + if osv != "" || formatted != "" { + b.Grow(len(osv) + len(formatted) + 3) // parens + maybe '+' + b.WriteByte('(') + if osv != "" { + b.WriteString(osv) + } + if formatted != "" { + b.WriteByte('+') + b.WriteString(formatted) + } + b.WriteByte(')') + } + + return path.Join(b.String(), platform.Architecture, platform.Variant) +} + +func formatOSFeatures(features []string) string { + if len(features) == 0 { + return "" + } - osOptions := encodeOSOption(platform.OSVersion) - features := platform.OSFeatures if !slices.IsSorted(features) { features = slices.Clone(features) slices.Sort(features) } + var b strings.Builder + var wrote bool + var prev string for _, f := range features { - osOptions += "+" + encodeOSOption(f) + if f == "" || f == prev { + // skip empty and duplicate values + continue + } + prev = f + if wrote { + b.WriteByte('+') + } + b.WriteString(encodeOSOption(f)) + wrote = true } - if osOptions != "" { - OSAndVersion := fmt.Sprintf("%s(%s)", platform.OS, osOptions) - return path.Join(OSAndVersion, platform.Architecture, platform.Variant) - } - return path.Join(platform.OS, platform.Architecture, platform.Variant) + return b.String() } // osOptionReplacer encodes characters in OS option values (version and diff --git a/vendor/modules.txt b/vendor/modules.txt index 865b04e424..8467b6e36a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -203,8 +203,8 @@ github.com/containerd/nri/types/v1 ## explicit; go 1.21 github.com/containerd/otelttrpc github.com/containerd/otelttrpc/internal -# github.com/containerd/platforms v1.0.0-rc.3 -## explicit; go 1.21 +# github.com/containerd/platforms v1.0.0-rc.4 +## explicit; go 1.24 github.com/containerd/platforms # github.com/containerd/plugin v1.0.0 ## explicit; go 1.20 From 146930e91de7598fa93161cb96d16208f1eff866 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Sat, 21 Mar 2026 04:07:58 +0800 Subject: [PATCH 2/5] api: add `os_features` to api/types/platform.proto Signed-off-by: Gao Xiang --- api/next.txtpb | 60 +++++- api/types/platform.pb.go | 42 ++-- api/types/platform.proto | 1 + api/types/platform_helpers.go | 2 + core/transfer/image/imagestore.go | 2 + go.mod | 2 + go.sum | 2 - .../containerd/containerd/api/LICENSE | 191 ------------------ .../containerd/api/types/platform.pb.go | 42 ++-- .../containerd/api/types/platform.proto | 1 + .../containerd/api/types/platform_helpers.go | 2 + vendor/modules.txt | 5 +- 12 files changed, 123 insertions(+), 229 deletions(-) delete mode 100644 vendor/github.com/containerd/containerd/api/LICENSE diff --git a/api/next.txtpb b/api/next.txtpb index dbb51f2920..5eb612df9f 100644 --- a/api/next.txtpb +++ b/api/next.txtpb @@ -25187,6 +25187,13 @@ file: { type: TYPE_STRING json_name: "osVersion" } + field: { + name: "os_features" + number: 5 + label: LABEL_REPEATED + type: TYPE_STRING + json_name: "osFeatures" + } } options: { go_package: "github.com/containerd/containerd/api/types;types" @@ -25195,7 +25202,7 @@ file: { location: { span: 16 span: 0 - span: 29 + span: 30 span: 1 } location: { @@ -25229,7 +25236,7 @@ file: { path: 0 span: 24 span: 0 - span: 29 + span: 30 span: 1 leading_comments: " Platform follows the structure of the OCI platform specification, from\n descriptors.\n" } @@ -25397,6 +25404,55 @@ file: { span: 22 span: 23 } + location: { + path: 4 + path: 0 + path: 2 + path: 4 + span: 29 + span: 2 + span: 34 + } + location: { + path: 4 + path: 0 + path: 2 + path: 4 + path: 4 + span: 29 + span: 2 + span: 10 + } + location: { + path: 4 + path: 0 + path: 2 + path: 4 + path: 5 + span: 29 + span: 11 + span: 17 + } + location: { + path: 4 + path: 0 + path: 2 + path: 4 + path: 1 + span: 29 + span: 18 + span: 29 + } + location: { + path: 4 + path: 0 + path: 2 + path: 4 + path: 3 + span: 29 + span: 32 + span: 33 + } } syntax: "proto3" buf_extension: { diff --git a/api/types/platform.pb.go b/api/types/platform.pb.go index 4ecd31cca2..947b520dba 100644 --- a/api/types/platform.pb.go +++ b/api/types/platform.pb.go @@ -42,10 +42,11 @@ type Platform struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - OS string `protobuf:"bytes,1,opt,name=os,proto3" json:"os,omitempty"` - Architecture string `protobuf:"bytes,2,opt,name=architecture,proto3" json:"architecture,omitempty"` - Variant string `protobuf:"bytes,3,opt,name=variant,proto3" json:"variant,omitempty"` - OSVersion string `protobuf:"bytes,4,opt,name=os_version,json=osVersion,proto3" json:"os_version,omitempty"` + OS string `protobuf:"bytes,1,opt,name=os,proto3" json:"os,omitempty"` + Architecture string `protobuf:"bytes,2,opt,name=architecture,proto3" json:"architecture,omitempty"` + Variant string `protobuf:"bytes,3,opt,name=variant,proto3" json:"variant,omitempty"` + OSVersion string `protobuf:"bytes,4,opt,name=os_version,json=osVersion,proto3" json:"os_version,omitempty"` + OSFeatures []string `protobuf:"bytes,5,rep,name=os_features,json=osFeatures,proto3" json:"os_features,omitempty"` } func (x *Platform) Reset() { @@ -108,23 +109,32 @@ func (x *Platform) GetOsVersion() string { return "" } +func (x *Platform) GetOsFeatures() []string { + if x != nil { + return x.OSFeatures + } + return nil +} + var File_types_platform_proto protoreflect.FileDescriptor var file_types_platform_proto_rawDesc = []byte{ 0x0a, 0x14, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x10, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, - 0x72, 0x64, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x22, 0x77, 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x74, - 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x02, 0x6f, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x61, 0x72, 0x63, 0x68, 0x69, 0x74, 0x65, 0x63, - 0x74, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, 0x72, 0x63, 0x68, - 0x69, 0x74, 0x65, 0x63, 0x74, 0x75, 0x72, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x61, 0x72, 0x69, - 0x61, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x61, 0x72, 0x69, 0x61, - 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x6f, 0x73, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6f, 0x73, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x42, 0x32, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x64, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x61, - 0x69, 0x6e, 0x65, 0x72, 0x64, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x3b, - 0x74, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x64, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x22, 0x98, 0x01, 0x0a, 0x08, 0x50, 0x6c, 0x61, + 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x02, 0x6f, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x61, 0x72, 0x63, 0x68, 0x69, 0x74, 0x65, + 0x63, 0x74, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, 0x72, 0x63, + 0x68, 0x69, 0x74, 0x65, 0x63, 0x74, 0x75, 0x72, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x61, 0x72, + 0x69, 0x61, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x61, 0x72, 0x69, + 0x61, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x6f, 0x73, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6f, 0x73, 0x56, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x73, 0x5f, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, + 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x6f, 0x73, 0x46, 0x65, 0x61, 0x74, 0x75, + 0x72, 0x65, 0x73, 0x42, 0x32, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x64, 0x2f, 0x63, 0x6f, 0x6e, + 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x64, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x79, 0x70, 0x65, + 0x73, 0x3b, 0x74, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/types/platform.proto b/api/types/platform.proto index c56b6de299..33ed85301c 100644 --- a/api/types/platform.proto +++ b/api/types/platform.proto @@ -27,4 +27,5 @@ message Platform { string architecture = 2; string variant = 3; string os_version = 4; + repeated string os_features = 5; } diff --git a/api/types/platform_helpers.go b/api/types/platform_helpers.go index d8c1a68770..ba1fec5778 100644 --- a/api/types/platform_helpers.go +++ b/api/types/platform_helpers.go @@ -28,6 +28,7 @@ func OCIPlatformToProto(platforms []oci.Platform) []*Platform { OSVersion: platforms[i].OSVersion, Architecture: platforms[i].Architecture, Variant: platforms[i].Variant, + OSFeatures: platforms[i].OSFeatures, } } return ap @@ -43,6 +44,7 @@ func OCIPlatformFromProto(platforms []*Platform) []oci.Platform { OSVersion: platforms[i].OSVersion, Architecture: platforms[i].Architecture, Variant: platforms[i].Variant, + OSFeatures: platforms[i].OSFeatures, } } return op diff --git a/core/transfer/image/imagestore.go b/core/transfer/image/imagestore.go index e0a2f47fd7..e22c290f51 100644 --- a/core/transfer/image/imagestore.go +++ b/core/transfer/image/imagestore.go @@ -425,6 +425,7 @@ func unpackToProto(uc []transfer.UnpackConfiguration) []*transfertypes.UnpackCon OS: uc[i].Platform.OS, Architecture: uc[i].Platform.Architecture, Variant: uc[i].Platform.Variant, + OSFeatures: uc[i].Platform.OSFeatures, } auc[i] = &transfertypes.UnpackConfiguration{ Platform: &p, @@ -442,6 +443,7 @@ func unpackFromProto(auc []*transfertypes.UnpackConfiguration) []transfer.Unpack uc[i].Platform.OS = auc[i].Platform.OS uc[i].Platform.Architecture = auc[i].Platform.Architecture uc[i].Platform.Variant = auc[i].Platform.Variant + uc[i].Platform.OSFeatures = auc[i].Platform.OSFeatures } } return uc diff --git a/go.mod b/go.mod index ae61e00f91..7e05fadf41 100644 --- a/go.mod +++ b/go.mod @@ -162,3 +162,5 @@ require ( sigs.k8s.io/yaml v1.6.0 // indirect tags.cncf.io/container-device-interface/specs-go v1.1.0 // indirect ) + +replace github.com/containerd/containerd/api => ./api diff --git a/go.sum b/go.sum index 85ab44794b..d9e17e8e30 100644 --- a/go.sum +++ b/go.sum @@ -43,8 +43,6 @@ github.com/containerd/cgroups/v3 v3.1.3 h1:eUNflyMddm18+yrDmZPn3jI7C5hJ9ahABE5q6 github.com/containerd/cgroups/v3 v3.1.3/go.mod h1:PKZ2AcWmSBsY/tJUVhtS/rluX0b1uq1GmPO1ElCmbOw= github.com/containerd/console v1.0.5 h1:R0ymNeydRqH2DmakFNdmjR2k0t7UPuiOV/N/27/qqsc= github.com/containerd/console v1.0.5/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk= -github.com/containerd/containerd/api v1.11.0-beta.0 h1:qtnn2fNjzVl82CRfzt6VvDikwQnMD66eq06Djb+I1Lc= -github.com/containerd/containerd/api v1.11.0-beta.0/go.mod h1:NBm1OAk8ZL+LG8R0ceObGxT5hbUYj7CzTmR3xh0DlMM= github.com/containerd/continuity v0.4.5 h1:ZRoN1sXq9u7V6QoHMcVWGhOwDFqZ4B9i5H6un1Wh0x4= github.com/containerd/continuity v0.4.5/go.mod h1:/lNJvtJKUQStBzpVQ1+rasXO1LAWtUQssk28EZvJ3nE= github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI= diff --git a/vendor/github.com/containerd/containerd/api/LICENSE b/vendor/github.com/containerd/containerd/api/LICENSE deleted file mode 100644 index 584149b6ee..0000000000 --- a/vendor/github.com/containerd/containerd/api/LICENSE +++ /dev/null @@ -1,191 +0,0 @@ - - Apache License - Version 2.0, January 2004 - https://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - Copyright The containerd Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/github.com/containerd/containerd/api/types/platform.pb.go b/vendor/github.com/containerd/containerd/api/types/platform.pb.go index 4ecd31cca2..947b520dba 100644 --- a/vendor/github.com/containerd/containerd/api/types/platform.pb.go +++ b/vendor/github.com/containerd/containerd/api/types/platform.pb.go @@ -42,10 +42,11 @@ type Platform struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - OS string `protobuf:"bytes,1,opt,name=os,proto3" json:"os,omitempty"` - Architecture string `protobuf:"bytes,2,opt,name=architecture,proto3" json:"architecture,omitempty"` - Variant string `protobuf:"bytes,3,opt,name=variant,proto3" json:"variant,omitempty"` - OSVersion string `protobuf:"bytes,4,opt,name=os_version,json=osVersion,proto3" json:"os_version,omitempty"` + OS string `protobuf:"bytes,1,opt,name=os,proto3" json:"os,omitempty"` + Architecture string `protobuf:"bytes,2,opt,name=architecture,proto3" json:"architecture,omitempty"` + Variant string `protobuf:"bytes,3,opt,name=variant,proto3" json:"variant,omitempty"` + OSVersion string `protobuf:"bytes,4,opt,name=os_version,json=osVersion,proto3" json:"os_version,omitempty"` + OSFeatures []string `protobuf:"bytes,5,rep,name=os_features,json=osFeatures,proto3" json:"os_features,omitempty"` } func (x *Platform) Reset() { @@ -108,23 +109,32 @@ func (x *Platform) GetOsVersion() string { return "" } +func (x *Platform) GetOsFeatures() []string { + if x != nil { + return x.OSFeatures + } + return nil +} + var File_types_platform_proto protoreflect.FileDescriptor var file_types_platform_proto_rawDesc = []byte{ 0x0a, 0x14, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x10, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, - 0x72, 0x64, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x22, 0x77, 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x74, - 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x02, 0x6f, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x61, 0x72, 0x63, 0x68, 0x69, 0x74, 0x65, 0x63, - 0x74, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, 0x72, 0x63, 0x68, - 0x69, 0x74, 0x65, 0x63, 0x74, 0x75, 0x72, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x61, 0x72, 0x69, - 0x61, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x61, 0x72, 0x69, 0x61, - 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x6f, 0x73, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6f, 0x73, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x42, 0x32, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x64, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x61, - 0x69, 0x6e, 0x65, 0x72, 0x64, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x3b, - 0x74, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x64, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x22, 0x98, 0x01, 0x0a, 0x08, 0x50, 0x6c, 0x61, + 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x02, 0x6f, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x61, 0x72, 0x63, 0x68, 0x69, 0x74, 0x65, + 0x63, 0x74, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, 0x72, 0x63, + 0x68, 0x69, 0x74, 0x65, 0x63, 0x74, 0x75, 0x72, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x61, 0x72, + 0x69, 0x61, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x61, 0x72, 0x69, + 0x61, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x6f, 0x73, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6f, 0x73, 0x56, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x73, 0x5f, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, + 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x6f, 0x73, 0x46, 0x65, 0x61, 0x74, 0x75, + 0x72, 0x65, 0x73, 0x42, 0x32, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x64, 0x2f, 0x63, 0x6f, 0x6e, + 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x64, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x79, 0x70, 0x65, + 0x73, 0x3b, 0x74, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/vendor/github.com/containerd/containerd/api/types/platform.proto b/vendor/github.com/containerd/containerd/api/types/platform.proto index c56b6de299..33ed85301c 100644 --- a/vendor/github.com/containerd/containerd/api/types/platform.proto +++ b/vendor/github.com/containerd/containerd/api/types/platform.proto @@ -27,4 +27,5 @@ message Platform { string architecture = 2; string variant = 3; string os_version = 4; + repeated string os_features = 5; } diff --git a/vendor/github.com/containerd/containerd/api/types/platform_helpers.go b/vendor/github.com/containerd/containerd/api/types/platform_helpers.go index d8c1a68770..ba1fec5778 100644 --- a/vendor/github.com/containerd/containerd/api/types/platform_helpers.go +++ b/vendor/github.com/containerd/containerd/api/types/platform_helpers.go @@ -28,6 +28,7 @@ func OCIPlatformToProto(platforms []oci.Platform) []*Platform { OSVersion: platforms[i].OSVersion, Architecture: platforms[i].Architecture, Variant: platforms[i].Variant, + OSFeatures: platforms[i].OSFeatures, } } return ap @@ -43,6 +44,7 @@ func OCIPlatformFromProto(platforms []*Platform) []oci.Platform { OSVersion: platforms[i].OSVersion, Architecture: platforms[i].Architecture, Variant: platforms[i].Variant, + OSFeatures: platforms[i].OSFeatures, } } return op diff --git a/vendor/modules.txt b/vendor/modules.txt index 8467b6e36a..6d420f883d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -114,8 +114,8 @@ github.com/containerd/cgroups/v3/cgroup2/stats # github.com/containerd/console v1.0.5 ## explicit; go 1.13 github.com/containerd/console -# github.com/containerd/containerd/api v1.11.0-beta.0 -## explicit; go 1.23.0 +# github.com/containerd/containerd/api v1.11.0-beta.0 => ./api +## explicit; go 1.24.0 github.com/containerd/containerd/api/events github.com/containerd/containerd/api/runtime/sandbox/v1 github.com/containerd/containerd/api/runtime/task/v2 @@ -991,3 +991,4 @@ tags.cncf.io/container-device-interface/pkg/parser # tags.cncf.io/container-device-interface/specs-go v1.1.0 ## explicit; go 1.19 tags.cncf.io/container-device-interface/specs-go +# github.com/containerd/containerd/api => ./api From cb93966b9f952c5f8f9aff0ba44b13ce6e26b8a8 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Sat, 21 Mar 2026 04:16:08 +0800 Subject: [PATCH 3/5] transfer: Default to the EROFS snapshotter and differ for EROFS images If no snapshotter is specified and `os.features` contains "erofs", unpacking should use the EROFS snapshotter and differ. This enhances the usability of native EROFS container images. Signed-off-by: Gao Xiang --- plugins/diff/erofs/plugin/plugin.go | 3 ++ plugins/transfer/plugin.go | 13 +++++- plugins/transfer/plugin_defaults_linux.go | 48 +++++++++++++++++++++++ plugins/transfer/plugin_defaults_other.go | 2 +- 4 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 plugins/transfer/plugin_defaults_linux.go diff --git a/plugins/diff/erofs/plugin/plugin.go b/plugins/diff/erofs/plugin/plugin.go index e45cdc74f0..955fa26655 100644 --- a/plugins/diff/erofs/plugin/plugin.go +++ b/plugins/diff/erofs/plugin/plugin.go @@ -69,6 +69,9 @@ func init() { p := platforms.DefaultSpec() p.OS = "linux" ic.Meta.Platforms = append(ic.Meta.Platforms, p) + // Select this differ for EROFS native images by default + p.OSFeatures = []string{"erofs"} + ic.Meta.Platforms = append(ic.Meta.Platforms, p) cs := md.(*metadata.DB).ContentStore() config := ic.Config.(*Config) diff --git a/plugins/transfer/plugin.go b/plugins/transfer/plugin.go index 7ac1086edf..64bbc6d6a4 100644 --- a/plugins/transfer/plugin.go +++ b/plugins/transfer/plugin.go @@ -102,6 +102,9 @@ func init() { sn := ms.Snapshotter(uc.Snapshotter) if sn == nil { + if uc.Optional { + continue + } return nil, fmt.Errorf("snapshotter %q not found: %w", uc.Snapshotter, errdefs.ErrNotFound) } var ( @@ -165,12 +168,15 @@ func init() { } } if applier == nil { + if uc.Optional { + continue + } return nil, fmt.Errorf("no matching diff plugins: %w", errdefs.ErrNotFound) } - // If CheckPlatformSupported is false, we will match all platforms + // If CheckPlatformSupported is false, platforms.OnlyOS() is applied if !config.CheckPlatformSupported { - target = platforms.All + target = platforms.OnlyOS(p) } up := unpack.Platform{ @@ -235,6 +241,9 @@ type unpackConfiguration struct { // LayerTypes are the allowed layer types for this unpack configuration LayerTypes []string `toml:"layer_types"` + + // Optional skips the configuration when initialization fails + Optional bool `toml:"optional"` } func defaultConfig() *transferConfig { diff --git a/plugins/transfer/plugin_defaults_linux.go b/plugins/transfer/plugin_defaults_linux.go new file mode 100644 index 0000000000..f3d3fef1d4 --- /dev/null +++ b/plugins/transfer/plugin_defaults_linux.go @@ -0,0 +1,48 @@ +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package transfer + +import ( + "github.com/containerd/containerd/v2/defaults" + "github.com/containerd/platforms" + + specs "github.com/opencontainers/image-spec/specs-go/v1" +) + +// Use EROFS snapshotter to extract EROFS native images +func erofsPlatformSpec() specs.Platform { + p := platforms.DefaultSpec() + p.OSFeatures = []string{"erofs"} + return p +} + +func defaultUnpackConfig() []unpackConfiguration { + return []unpackConfiguration{ + { + Platform: platforms.Format(platforms.DefaultSpec()), + Snapshotter: defaults.DefaultSnapshotter, + Differ: defaults.DefaultDiffer, + }, + + { + Platform: platforms.FormatAll(erofsPlatformSpec()), + Snapshotter: "erofs", + Differ: "erofs", + Optional: true, + }, + } +} diff --git a/plugins/transfer/plugin_defaults_other.go b/plugins/transfer/plugin_defaults_other.go index de62e5c681..dd15a18710 100644 --- a/plugins/transfer/plugin_defaults_other.go +++ b/plugins/transfer/plugin_defaults_other.go @@ -1,4 +1,4 @@ -//go:build !windows && !darwin +//go:build !windows && !darwin && !linux /* Copyright The containerd Authors. From f8367b8ad260095a55661aaa87af8f3e1adc6af6 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Wed, 1 Apr 2026 01:59:31 +0800 Subject: [PATCH 4/5] client: remove toPlatforms() Just use apitypes.OCIPlatformFromProto(). Suggested-by: Jin Dong Signed-off-by: Gao Xiang --- client/client.go | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/client/client.go b/client/client.go index 2af39db316..b7ca2056f8 100644 --- a/client/client.go +++ b/client/client.go @@ -953,22 +953,10 @@ func (c *Client) GetSnapshotterSupportedPlatforms(ctx context.Context, snapshott } sn := resp.Plugins[0] - snPlatforms := toPlatforms(sn.Platforms) + snPlatforms := apitypes.OCIPlatformFromProto(sn.Platforms) return platforms.Any(snPlatforms...), nil } -func toPlatforms(pt []*apitypes.Platform) []ocispec.Platform { - platforms := make([]ocispec.Platform, len(pt)) - for i, p := range pt { - platforms[i] = ocispec.Platform{ - Architecture: p.Architecture, - OS: p.OS, - Variant: p.Variant, - } - } - return platforms -} - // GetSnapshotterCapabilities returns the capabilities of a snapshotter. func (c *Client) GetSnapshotterCapabilities(ctx context.Context, snapshotterName string) ([]string, error) { filters := []string{fmt.Sprintf("type==%s, id==%s", plugins.SnapshotPlugin, snapshotterName)} From 940076477e581c28307ad326b3cd8244ba6cb8e4 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Sat, 21 Mar 2026 13:12:05 +0800 Subject: [PATCH 5/5] client/image: check if the snapshotter supports forcely if `os.feature` is set If no snapshotter is specified, container run selects the default snapshotter. However, if `os.features` is set, we should always call `checkSnapshotterSupport()`. This ensures containerd clients report a clear error: ``` ctr: snapshotter overlayfs does not support platform {amd64 linux [erofs] } for image sha256:[] ``` instead of the confusing layer extraction error: ``` ctr: apply layer error for "": failed to extract layer sha256:[]: failed to get stream processor for application/vnd.erofs.layer.v1: no processor for media-type ``` Signed-off-by: Gao Xiang --- client/image.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/client/image.go b/client/image.go index 5122aa0620..49fe17be7b 100644 --- a/client/image.go +++ b/client/image.go @@ -337,10 +337,10 @@ func (i *image) Unpack(ctx context.Context, snapshotterName string, opts ...Unpa if err != nil { return err } - if config.CheckPlatformSupported { - if err := i.checkSnapshotterSupport(ctx, snapshotterName, manifest); err != nil { - return err - } + + if err := i.checkSnapshotterSupport(ctx, snapshotterName, manifest, + config.CheckPlatformSupported); err != nil { + return err } for _, layer := range layers { @@ -421,13 +421,18 @@ func (i *image) getLayers(ctx context.Context, manifest ocispec.Manifest) ([]roo return layers, nil } -func (i *image) checkSnapshotterSupport(ctx context.Context, snapshotterName string, manifest ocispec.Manifest) error { - snapshotterPlatformMatcher, err := i.client.GetSnapshotterSupportedPlatforms(ctx, snapshotterName) +func (i *image) checkSnapshotterSupport(ctx context.Context, snapshotterName string, + manifest ocispec.Manifest, checkSnapshotterSupport bool) error { + manifestPlatform, err := images.ConfigPlatform(ctx, i.ContentStore(), manifest.Config) if err != nil { return err } - manifestPlatform, err := images.ConfigPlatform(ctx, i.ContentStore(), manifest.Config) + if len(manifestPlatform.OSFeatures) == 0 && !checkSnapshotterSupport { + return nil + } + + snapshotterPlatformMatcher, err := i.client.GetSnapshotterSupportedPlatforms(ctx, snapshotterName) if err != nil { return err }