Skip to content

Commit 2fec6c4

Browse files
authored
Merge pull request #24 from kiashok/add-ws2025
Add WS2025 to Windows matcher and code optimizations
2 parents e3566b8 + 8447b0a commit 2fec6c4

3 files changed

Lines changed: 100 additions & 51 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
env:
1010
# Go version we currently use to build containerd across all CI.
1111
# Note: don't forget to update `Binaries` step, as it contains the matrix of all supported Go versions.
12-
GO_VERSION: "1.22.8"
12+
GO_VERSION: "1.23.9"
1313

1414
permissions: # added using https://github.com/step-security/secure-workflows
1515
contents: read
@@ -64,7 +64,7 @@ jobs:
6464
path: src/github.com/containerd/platforms
6565
fetch-depth: 25
6666

67-
- uses: containerd/project-checks@v1.1.0
67+
- uses: containerd/project-checks@v1.2.2
6868
with:
6969
working-directory: src/github.com/containerd/platforms
7070
repo-access-token: ${{ secrets.GITHUB_TOKEN }}

platform_windows_compat.go

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,30 @@ const (
4242
// rs5 (version 1809, codename "Redstone 5") corresponds to Windows Server
4343
// 2019 (ltsc2019), and Windows 10 (October 2018 Update).
4444
rs5 = 17763
45+
// ltsc2019 (Windows Server 2019) is an alias for [RS5].
46+
ltsc2019 = rs5
4547

4648
// v21H2Server corresponds to Windows Server 2022 (ltsc2022).
4749
v21H2Server = 20348
50+
// ltsc2022 (Windows Server 2022) is an alias for [v21H2Server]
51+
ltsc2022 = v21H2Server
4852

4953
// v22H2Win11 corresponds to Windows 11 (2022 Update).
5054
v22H2Win11 = 22621
55+
56+
// v23H2 is the 23H2 release in the Windows Server annual channel.
57+
v23H2 = 25398
58+
59+
// Windows Server 2025 build 26100
60+
v25H1Server = 26100
61+
ltsc2025 = v25H1Server
5162
)
5263

5364
// List of stable ABI compliant ltsc releases
5465
// Note: List must be sorted in ascending order
5566
var compatLTSCReleases = []uint16{
56-
v21H2Server,
67+
ltsc2022,
68+
ltsc2025,
5769
}
5870

5971
// CheckHostAndContainerCompat checks if given host and container
@@ -70,18 +82,27 @@ func checkWindowsHostAndContainerCompat(host, ctr windowsOSVersion) bool {
7082
}
7183

7284
// If host is < WS 2022, exact version match is required
73-
if host.Build < v21H2Server {
85+
if host.Build < ltsc2022 {
7486
return host.Build == ctr.Build
7587
}
7688

77-
var supportedLtscRelease uint16
89+
// Find the latest LTSC version that is earlier than the host version.
90+
// This is the earliest version of container that the host can run.
91+
//
92+
// If the host version is an LTSC, then it supports compatibility with
93+
// everything from the previous LTSC up to itself, so we want supportedLTSCRelease
94+
// to be the previous entry.
95+
//
96+
// If no match is found, then we know that the host is LTSC2022 exactly,
97+
// since we already checked that it's not less than LTSC2022.
98+
var supportedLTSCRelease uint16 = ltsc2022
7899
for i := len(compatLTSCReleases) - 1; i >= 0; i-- {
79-
if host.Build >= compatLTSCReleases[i] {
80-
supportedLtscRelease = compatLTSCReleases[i]
100+
if host.Build > compatLTSCReleases[i] {
101+
supportedLTSCRelease = compatLTSCReleases[i]
81102
break
82103
}
83104
}
84-
return ctr.Build >= supportedLtscRelease && ctr.Build <= host.Build
105+
return supportedLTSCRelease <= ctr.Build && ctr.Build <= host.Build
85106
}
86107

87108
func getWindowsOSVersion(osVersionPrefix string) windowsOSVersion {

platform_windows_compat_test.go

Lines changed: 71 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -17,68 +17,96 @@
1717
package platforms
1818

1919
import (
20+
"fmt"
2021
"testing"
2122
)
2223

23-
// Test the platform compatibility of the different
24-
// OS Versions considering two ltsc container image
25-
// versions (ltsc2019, ltsc2022)
24+
// Test the platform compatibility of the different OS Versions
2625
func Test_PlatformCompat(t *testing.T) {
27-
for testName, tc := range map[string]struct {
28-
hostOs uint16
29-
ctrOs uint16
26+
for _, tc := range []struct {
27+
hostOS uint16
28+
ctrOS uint16
3029
shouldRun bool
3130
}{
32-
"RS5Host_ltsc2019": {
33-
hostOs: rs5,
34-
ctrOs: rs5,
31+
{
32+
hostOS: ltsc2019,
33+
ctrOS: ltsc2019,
3534
shouldRun: true,
3635
},
37-
"RS5Host_ltsc2022": {
38-
hostOs: rs5,
39-
ctrOs: v21H2Server,
36+
{
37+
hostOS: ltsc2019,
38+
ctrOS: ltsc2022,
4039
shouldRun: false,
4140
},
42-
"WS2022Host_ltsc2019": {
43-
hostOs: v21H2Server,
44-
ctrOs: rs5,
41+
{
42+
hostOS: ltsc2022,
43+
ctrOS: ltsc2019,
4544
shouldRun: false,
4645
},
47-
"WS2022Host_ltsc2022": {
48-
hostOs: v21H2Server,
49-
ctrOs: v21H2Server,
46+
{
47+
hostOS: ltsc2022,
48+
ctrOS: ltsc2022,
5049
shouldRun: true,
5150
},
52-
"Wind11Host_ltsc2019": {
53-
hostOs: v22H2Win11,
54-
ctrOs: rs5,
51+
{
52+
hostOS: v22H2Win11,
53+
ctrOS: ltsc2019,
5554
shouldRun: false,
5655
},
57-
"Wind11Host_ltsc2022": {
58-
hostOs: v22H2Win11,
59-
ctrOs: v21H2Server,
56+
{
57+
hostOS: v22H2Win11,
58+
ctrOS: ltsc2022,
59+
shouldRun: true,
60+
},
61+
{
62+
hostOS: v23H2,
63+
ctrOS: ltsc2019,
64+
shouldRun: false,
65+
},
66+
{
67+
hostOS: v23H2,
68+
ctrOS: ltsc2022,
69+
shouldRun: true,
70+
},
71+
{
72+
hostOS: ltsc2025,
73+
ctrOS: ltsc2022,
74+
shouldRun: true,
75+
},
76+
{
77+
hostOS: ltsc2022,
78+
ctrOS: ltsc2025,
79+
shouldRun: false,
80+
},
81+
{
82+
hostOS: ltsc2022,
83+
ctrOS: v22H2Win11,
84+
shouldRun: false,
85+
},
86+
{
87+
hostOS: ltsc2025,
88+
ctrOS: v22H2Win11,
6089
shouldRun: true,
6190
},
6291
} {
63-
// Check if ltsc2019/ltsc2022 guest images are compatible on
64-
// the given host OS versions
65-
//
66-
hostOSVersion := windowsOSVersion{
67-
MajorVersion: 10,
68-
MinorVersion: 0,
69-
Build: tc.hostOs,
70-
}
71-
ctrOSVersion := windowsOSVersion{
72-
MajorVersion: 10,
73-
MinorVersion: 0,
74-
Build: tc.ctrOs,
75-
}
76-
if checkWindowsHostAndContainerCompat(hostOSVersion, ctrOSVersion) != tc.shouldRun {
77-
var expectedResultStr string
78-
if !tc.shouldRun {
79-
expectedResultStr = " NOT"
92+
t.Run(fmt.Sprintf("Host_%d_Ctr_%d", tc.hostOS, tc.ctrOS), func(t *testing.T) {
93+
hostOSVersion := windowsOSVersion{
94+
MajorVersion: 10,
95+
MinorVersion: 0,
96+
Build: tc.hostOS,
97+
}
98+
ctrOSVersion := windowsOSVersion{
99+
MajorVersion: 10,
100+
MinorVersion: 0,
101+
Build: tc.ctrOS,
102+
}
103+
if checkWindowsHostAndContainerCompat(hostOSVersion, ctrOSVersion) != tc.shouldRun {
104+
var expectedResultStr string
105+
if !tc.shouldRun {
106+
expectedResultStr = " NOT"
107+
}
108+
t.Fatalf("host %v should%s be able to run guest %v", tc.hostOS, expectedResultStr, tc.ctrOS)
80109
}
81-
t.Fatalf("Failed %v: host %v should%s be able to run guest %v", testName, tc.hostOs, expectedResultStr, tc.ctrOs)
82-
}
110+
})
83111
}
84112
}

0 commit comments

Comments
 (0)