Skip to content

Commit

Permalink
Merge pull request #2327 from kevpar/compat-ws2025
Browse files Browse the repository at this point in the history
osversion: Add new versions, fix compat bug, improve tests
  • Loading branch information
kevpar authored Dec 17, 2024
2 parents f234e83 + bacda39 commit d9a4231
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 49 deletions.
22 changes: 16 additions & 6 deletions osversion/platform_compat_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package osversion
// List of stable ABI compliant ltsc releases
// Note: List must be sorted in ascending order
var compatLTSCReleases = []uint16{
V21H2Server,
LTSC2022,
LTSC2025,
}

// CheckHostAndContainerCompat checks if given host and container
Expand All @@ -20,16 +21,25 @@ func CheckHostAndContainerCompat(host, ctr OSVersion) bool {
}

// If host is < WS 2022, exact version match is required
if host.Build < V21H2Server {
if host.Build < LTSC2022 {
return host.Build == ctr.Build
}

var supportedLtscRelease uint16
// Find the latest LTSC version that is earlier than the host version.
// This is the earliest version of container that the host can run.
//
// If the host version is an LTSC, then it supports compatibility with
// everything from the previous LTSC up to itself, so we want supportedLTSCRelease
// to be the previous entry.
//
// If no match is found, then we know that the host is LTSC2022 exactly,
// since we already checked that it's not less than LTSC2022.
var supportedLTSCRelease uint16 = LTSC2022
for i := len(compatLTSCReleases) - 1; i >= 0; i-- {
if host.Build >= compatLTSCReleases[i] {
supportedLtscRelease = compatLTSCReleases[i]
if host.Build > compatLTSCReleases[i] {
supportedLTSCRelease = compatLTSCReleases[i]
break
}
}
return ctr.Build >= supportedLtscRelease && ctr.Build <= host.Build
return supportedLTSCRelease <= ctr.Build && ctr.Build <= host.Build
}
104 changes: 61 additions & 43 deletions osversion/platform_compat_windows_test.go
Original file line number Diff line number Diff line change
@@ -1,68 +1,86 @@
package osversion

import (
"fmt"
"testing"
)

// Test the platform compatibility of the different
// OS Versions considering two ltsc container image
// versions (ltsc2019, ltsc2022)
// Test the platform compatibility of the different OS Versions
func Test_PlatformCompat(t *testing.T) {
for testName, tc := range map[string]struct {
hostOs uint16
ctrOs uint16
for _, tc := range []struct {
hostOS uint16
ctrOS uint16
shouldRun bool
}{
"RS5Host_ltsc2019": {
hostOs: RS5,
ctrOs: RS5,
{
hostOS: LTSC2019,
ctrOS: LTSC2019,
shouldRun: true,
},
"RS5Host_ltsc2022": {
hostOs: RS5,
ctrOs: V21H2Server,
{
hostOS: LTSC2019,
ctrOS: LTSC2022,
shouldRun: false,
},
"WS2022Host_ltsc2019": {
hostOs: V21H2Server,
ctrOs: RS5,
{
hostOS: LTSC2022,
ctrOS: LTSC2019,
shouldRun: false,
},
"WS2022Host_ltsc2022": {
hostOs: V21H2Server,
ctrOs: V21H2Server,
{
hostOS: LTSC2022,
ctrOS: LTSC2022,
shouldRun: true,
},
"Wind11Host_ltsc2019": {
hostOs: V22H2Win11,
ctrOs: RS5,
{
hostOS: V22H2Win11,
ctrOS: LTSC2019,
shouldRun: false,
},
"Wind11Host_ltsc2022": {
hostOs: V22H2Win11,
ctrOs: V21H2Server,
{
hostOS: V22H2Win11,
ctrOS: LTSC2022,
shouldRun: true,
},
{
hostOS: LTSC2025,
ctrOS: LTSC2022,
shouldRun: true,
},
{
hostOS: LTSC2022,
ctrOS: LTSC2025,
shouldRun: false,
},
{
hostOS: LTSC2022,
ctrOS: V22H2Win11,
shouldRun: false,
},
{
hostOS: LTSC2025,
ctrOS: V22H2Win11,
shouldRun: true,
},
} {
// Check if ltsc2019/ltsc2022 guest images are compatible on
// the given host OS versions
//
hostOSVersion := OSVersion{
MajorVersion: 10,
MinorVersion: 0,
Build: tc.hostOs,
}
ctrOSVersion := OSVersion{
MajorVersion: 10,
MinorVersion: 0,
Build: tc.ctrOs,
}
if CheckHostAndContainerCompat(hostOSVersion, ctrOSVersion) != tc.shouldRun {
var expectedResultStr string
if !tc.shouldRun {
expectedResultStr = " NOT"
t.Run(fmt.Sprintf("Host_%d_Ctr_%d", tc.hostOS, tc.ctrOS), func(t *testing.T) {
hostOSVersion := OSVersion{
MajorVersion: 10,
MinorVersion: 0,
Build: tc.hostOS,
}
ctrOSVersion := OSVersion{
MajorVersion: 10,
MinorVersion: 0,
Build: tc.ctrOS,
}
if CheckHostAndContainerCompat(hostOSVersion, ctrOSVersion) != tc.shouldRun {
var expectedResultStr string
if !tc.shouldRun {
expectedResultStr = " NOT"
}
t.Fatalf("host %v should%s be able to run guest %v", tc.hostOS, expectedResultStr, tc.ctrOS)
}
t.Fatalf("Failed %v: host %v should%s be able to run guest %v", testName, tc.hostOs, expectedResultStr, tc.ctrOs)
}
})
}
}
4 changes: 4 additions & 0 deletions osversion/windowsbuilds.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ const (
// V22H2Win11 corresponds to Windows 11 (2022 Update).
V22H2Win11 = 22621

// V23H2 is the 23H2 release in the Windows Server annual channel.
V23H2 = 25398

// Windows Server 2025 build 26100
V25H1Server = 26100
LTSC2025 = V25H1Server
)

0 comments on commit d9a4231

Please sign in to comment.