Skip to content

Commit 8442521

Browse files
committed
Add fallback for windows platforms without osversion
The background for this change: 1. Windows host-process containers do not have an OS version set 2. Buildx v0.10 started pushing manifest lists by default, but it never has the OSVersion in the platform data (not that there is any way to specify what particular OS version you want). The change means that containerd cannot run images created with the new buildx on Windows because there is no matching OSVersion in the list of manifests. Signed-off-by: Brian Goff <[email protected]>
1 parent edb8eba commit 8442521

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

platforms/defaults_windows.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ func (m windowsmatcher) Match(p specs.Platform) bool {
5050
match := m.defaultMatcher.Match(p)
5151

5252
if match && m.OS == "windows" {
53-
return strings.HasPrefix(p.OSVersion, m.osVersionPrefix) && m.defaultMatcher.Match(p)
53+
if strings.HasPrefix(p.OSVersion, m.osVersionPrefix) {
54+
return true
55+
}
56+
return p.OSVersion == ""
5457
}
5558

5659
return match

platforms/defaults_windows_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func TestMatchComparerMatch_WCOW(t *testing.T) {
128128
Architecture: "amd64",
129129
OS: "windows",
130130
},
131-
match: false,
131+
match: true,
132132
},
133133
{
134134
platform: imagespec.Platform{
@@ -251,11 +251,11 @@ func TestMatchComparerLess(t *testing.T) {
251251
{
252252
Architecture: "amd64",
253253
OS: "windows",
254-
OSVersion: "10.0.17764.1",
255254
},
256255
{
257256
Architecture: "amd64",
258257
OS: "windows",
258+
OSVersion: "10.0.17764.1",
259259
},
260260
{
261261
Architecture: "amd64",

platforms/platforms_windows_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,23 @@ package platforms
1919
import (
2020
"testing"
2121

22+
specs "github.com/opencontainers/image-spec/specs-go/v1"
2223
"github.com/stretchr/testify/require"
2324
)
2425

2526
func TestNormalize(t *testing.T) {
2627
require.Equal(t, DefaultSpec(), Normalize(DefaultSpec()))
2728
}
29+
30+
func TestFallbackOnOSVersion(t *testing.T) {
31+
p := specs.Platform{
32+
OS: "windows",
33+
Architecture: "amd64",
34+
OSVersion: "99.99.99.99",
35+
}
36+
37+
other := specs.Platform{OS: p.OS, Architecture: p.Architecture}
38+
39+
m := NewMatcher(p)
40+
require.True(t, m.Match(other))
41+
}

0 commit comments

Comments
 (0)