Skip to content

Commit 8e8c3c1

Browse files
authored
Merge pull request #5919 from k8s-infra-cherrypick-robot/cherry-pick-5867-to-release-1.21
[release-1.21] Don't take windows capi image versions into consideration if no windows machines
2 parents a1a2c52 + 11c202f commit 8e8c3c1

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

test/e2e/helpers.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -692,15 +692,27 @@ func resolveKubetestRepoListPath(version string, path string) (string, error) {
692692
// that has an existing capi offer image available. For example, if the version is "stable-1.22", the function will set it to the latest 1.22 version that has a published reference image.
693693
func resolveKubernetesVersions(config *clusterctl.E2EConfig) {
694694
linuxVersions := getVersionsInCommunityGallery(context.TODO(), os.Getenv(AzureLocation), capiCommunityGallery, "capi-ubun2-2404")
695-
windowsVersions := getVersionsInCommunityGallery(context.TODO(), os.Getenv(AzureLocation), capiCommunityGallery, "capi-win-2019-containerd")
696695
flatcarK8sVersions := getFlatcarK8sVersions(context.TODO(), os.Getenv(AzureLocation), flatcarCAPICommunityGallery)
697696

698-
// find the intersection of ubuntu and windows versions available, since we need an image for both.
699697
var versions semver.Versions
700-
for k, v := range linuxVersions {
701-
if _, ok := windowsVersions[k]; ok {
698+
699+
// Check if Windows testing is explicitly disabled via TEST_WINDOWS environment variable
700+
testWindows := os.Getenv("TEST_WINDOWS")
701+
windowsRequired := testWindows != "false"
702+
703+
if windowsRequired {
704+
windowsVersions := getVersionsInCommunityGallery(context.TODO(), os.Getenv(AzureLocation), capiCommunityGallery, "capi-win-2019-containerd")
705+
for k, v := range linuxVersions {
706+
if _, ok := windowsVersions[k]; ok {
707+
versions = append(versions, v)
708+
}
709+
}
710+
Logf("Windows machines required, using intersection of Linux and Windows versions")
711+
} else {
712+
for _, v := range linuxVersions {
702713
versions = append(versions, v)
703714
}
715+
Logf("No Windows machines required, using Linux versions only")
704716
}
705717

706718
if config.HasVariable(capi_e2e.KubernetesVersion) {

0 commit comments

Comments
 (0)