From 619f18a22c467ee3c92f4730b0295d3bcf651dc0 Mon Sep 17 00:00:00 2001 From: Daniel Canter Date: Mon, 13 Sep 2021 17:13:51 -0700 Subject: [PATCH 1/5] Add ws2022 image/build to cri-integration tests This change adds a new case to the getWindowsServerCoreImage and getWindowsNanoserverImage functions to return ws2022 on a ws2022 or higher build. The higher case is because of some recent efforts to improve down-level compatability for Windows container images. For reference, the ltsc2022 image works on a win11 host without hypervisor isolation. Signed-off-by: Daniel Canter --- test/cri-containerd/main_test.go | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/test/cri-containerd/main_test.go b/test/cri-containerd/main_test.go index 5c362b1acd..5dc1091736 100644 --- a/test/cri-containerd/main_test.go +++ b/test/cri-containerd/main_test.go @@ -159,6 +159,13 @@ func requireBinary(t *testing.T, binary string) string { } func getWindowsNanoserverImage(build uint16) string { + // Due to some efforts in improving down-level compatibility for Windows containers (see + // https://techcommunity.microsoft.com/t5/containers/windows-server-2022-and-beyond-for-containers/ba-p/2712487) + // the ltsc2022 image should continue to work on builds ws2022 and onwards. The panic for "unsupported build" + // should only be triggered if the user is on a build older than RS5 or 21h1 now. + if build > osversion.V21H2 { + build = osversion.V21H2 + } switch build { case osversion.RS5: return "mcr.microsoft.com/windows/nanoserver:1809" @@ -170,23 +177,27 @@ func getWindowsNanoserverImage(build uint16) string { return "mcr.microsoft.com/windows/nanoserver:2004" case osversion.V20H2: return "mcr.microsoft.com/windows/nanoserver:2009" + case osversion.V21H2: + return "mcr.microsoft.com/windows/nanoserver:ltsc2022" default: panic("unsupported build") } } func getWindowsServerCoreImage(build uint16) string { - switch build { - case osversion.RS5: + switch b := build; { + case b == osversion.RS5: return "mcr.microsoft.com/windows/servercore:1809" - case osversion.V19H1: + case b == osversion.V19H1: return "mcr.microsoft.com/windows/servercore:1903" - case osversion.V19H2: + case b == osversion.V19H2: return "mcr.microsoft.com/windows/servercore:1909" - case osversion.V20H1: + case b == osversion.V20H1: return "mcr.microsoft.com/windows/servercore:2004" - case osversion.V20H2: + case b == osversion.V20H2: return "mcr.microsoft.com/windows/servercore:2009" + case b >= osversion.V21H2: + return "mcr.microsoft.com/windows/servercore:ltsc2022" default: panic("unsupported build") } From 38971c57e219cd9367b602f608185a6f738bd81c Mon Sep 17 00:00:00 2001 From: Daniel Canter Date: Thu, 16 Sep 2021 12:27:05 -0700 Subject: [PATCH 2/5] Make comment about cri-containerd test panic more clear It used to read "The panic for "unsupported build" should only be triggered if the user is on a build older than RS5 or 21h1 now." This is a bit confusing and is more clear if this was worded as "if the user is on 21H1 or a build older than RS5". Signed-off-by: Daniel Canter --- test/cri-containerd/main_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cri-containerd/main_test.go b/test/cri-containerd/main_test.go index 5dc1091736..a940076da9 100644 --- a/test/cri-containerd/main_test.go +++ b/test/cri-containerd/main_test.go @@ -162,7 +162,7 @@ func getWindowsNanoserverImage(build uint16) string { // Due to some efforts in improving down-level compatibility for Windows containers (see // https://techcommunity.microsoft.com/t5/containers/windows-server-2022-and-beyond-for-containers/ba-p/2712487) // the ltsc2022 image should continue to work on builds ws2022 and onwards. The panic for "unsupported build" - // should only be triggered if the user is on a build older than RS5 or 21h1 now. + // should only be triggered if the user is on 21h1 or a build older than RS5 now. if build > osversion.V21H2 { build = osversion.V21H2 } From af9e01f92621cccf296c7c57130bc1a1f8e3a9fe Mon Sep 17 00:00:00 2001 From: Daniel Canter Date: Thu, 11 Nov 2021 18:46:44 -0800 Subject: [PATCH 3/5] Use new 21h2 server definitions As three different builds of windows have the 21h2 moniker, use the server 21h2 definition Signed-off-by: Daniel Canter --- test/cri-containerd/main_test.go | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/test/cri-containerd/main_test.go b/test/cri-containerd/main_test.go index a940076da9..9175d9b420 100644 --- a/test/cri-containerd/main_test.go +++ b/test/cri-containerd/main_test.go @@ -163,8 +163,8 @@ func getWindowsNanoserverImage(build uint16) string { // https://techcommunity.microsoft.com/t5/containers/windows-server-2022-and-beyond-for-containers/ba-p/2712487) // the ltsc2022 image should continue to work on builds ws2022 and onwards. The panic for "unsupported build" // should only be triggered if the user is on 21h1 or a build older than RS5 now. - if build > osversion.V21H2 { - build = osversion.V21H2 + if build > osversion.V21H2Server { + build = osversion.V21H2Server } switch build { case osversion.RS5: @@ -177,7 +177,7 @@ func getWindowsNanoserverImage(build uint16) string { return "mcr.microsoft.com/windows/nanoserver:2004" case osversion.V20H2: return "mcr.microsoft.com/windows/nanoserver:2009" - case osversion.V21H2: + case osversion.V21H2Server: return "mcr.microsoft.com/windows/nanoserver:ltsc2022" default: panic("unsupported build") @@ -185,18 +185,25 @@ func getWindowsNanoserverImage(build uint16) string { } func getWindowsServerCoreImage(build uint16) string { - switch b := build; { - case b == osversion.RS5: + // Due to some efforts in improving down-level compatibility for Windows containers (see + // https://techcommunity.microsoft.com/t5/containers/windows-server-2022-and-beyond-for-containers/ba-p/2712487) + // the ltsc2022 image should continue to work on builds ws2022 and onwards. The panic for "unsupported build" + // should only be triggered if the user is on 21h1 or a build older than RS5 now. + if build > osversion.V21H2Server { + build = osversion.V21H2Server + } + switch build { + case osversion.RS5: return "mcr.microsoft.com/windows/servercore:1809" - case b == osversion.V19H1: + case osversion.V19H1: return "mcr.microsoft.com/windows/servercore:1903" - case b == osversion.V19H2: + case osversion.V19H2: return "mcr.microsoft.com/windows/servercore:1909" - case b == osversion.V20H1: + case osversion.V20H1: return "mcr.microsoft.com/windows/servercore:2004" - case b == osversion.V20H2: + case osversion.V20H2: return "mcr.microsoft.com/windows/servercore:2009" - case b >= osversion.V21H2: + case osversion.V21H2Server: return "mcr.microsoft.com/windows/servercore:ltsc2022" default: panic("unsupported build") From 6388b446cf5cef3f4e951d6ad5c865dcba364c36 Mon Sep 17 00:00:00 2001 From: Daniel Canter Date: Thu, 18 Nov 2021 16:24:47 -0800 Subject: [PATCH 4/5] PR Feedback Move build check to default case. Signed-off-by: Daniel Canter --- test/cri-containerd/main_test.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/test/cri-containerd/main_test.go b/test/cri-containerd/main_test.go index 9175d9b420..368804349d 100644 --- a/test/cri-containerd/main_test.go +++ b/test/cri-containerd/main_test.go @@ -159,13 +159,6 @@ func requireBinary(t *testing.T, binary string) string { } func getWindowsNanoserverImage(build uint16) string { - // Due to some efforts in improving down-level compatibility for Windows containers (see - // https://techcommunity.microsoft.com/t5/containers/windows-server-2022-and-beyond-for-containers/ba-p/2712487) - // the ltsc2022 image should continue to work on builds ws2022 and onwards. The panic for "unsupported build" - // should only be triggered if the user is on 21h1 or a build older than RS5 now. - if build > osversion.V21H2Server { - build = osversion.V21H2Server - } switch build { case osversion.RS5: return "mcr.microsoft.com/windows/nanoserver:1809" @@ -180,6 +173,13 @@ func getWindowsNanoserverImage(build uint16) string { case osversion.V21H2Server: return "mcr.microsoft.com/windows/nanoserver:ltsc2022" default: + // Due to some efforts in improving down-level compatibility for Windows containers (see + // https://techcommunity.microsoft.com/t5/containers/windows-server-2022-and-beyond-for-containers/ba-p/2712487) + // the ltsc2022 image should continue to work on builds ws2022 and onwards. With this in mind, + // if there's no mapping for the host build, just use the Windows Server 2022 image. + if build > osversion.V21H2Server { + return "mcr.microsoft.com/windows/nanoserver:ltsc2022" + } panic("unsupported build") } } @@ -206,6 +206,13 @@ func getWindowsServerCoreImage(build uint16) string { case osversion.V21H2Server: return "mcr.microsoft.com/windows/servercore:ltsc2022" default: + // Due to some efforts in improving down-level compatibility for Windows containers (see + // https://techcommunity.microsoft.com/t5/containers/windows-server-2022-and-beyond-for-containers/ba-p/2712487) + // the ltsc2022 image should continue to work on builds ws2022 and onwards. With this in mind, + // if there's no mapping for the host build, just use the Windows Server 2022 image. + if build > osversion.V21H2Server { + return "mcr.microsoft.com/windows/servercore:ltsc2022" + } panic("unsupported build") } } From 8cec0e83eae90742d4f6ee4263832a2a6d037700 Mon Sep 17 00:00:00 2001 From: Daniel Canter Date: Wed, 1 Dec 2021 08:16:16 -0800 Subject: [PATCH 5/5] Fix duplicated comment/build assignment There was a leftover block of code that assigned the build to ltsc2022 at the top of getWindowsServerCoreImage, but it was also assigned in the default case of the switch statement. Signed-off-by: Daniel Canter --- test/cri-containerd/main_test.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/test/cri-containerd/main_test.go b/test/cri-containerd/main_test.go index 368804349d..62dba6a7cd 100644 --- a/test/cri-containerd/main_test.go +++ b/test/cri-containerd/main_test.go @@ -185,13 +185,6 @@ func getWindowsNanoserverImage(build uint16) string { } func getWindowsServerCoreImage(build uint16) string { - // Due to some efforts in improving down-level compatibility for Windows containers (see - // https://techcommunity.microsoft.com/t5/containers/windows-server-2022-and-beyond-for-containers/ba-p/2712487) - // the ltsc2022 image should continue to work on builds ws2022 and onwards. The panic for "unsupported build" - // should only be triggered if the user is on 21h1 or a build older than RS5 now. - if build > osversion.V21H2Server { - build = osversion.V21H2Server - } switch build { case osversion.RS5: return "mcr.microsoft.com/windows/servercore:1809"