Skip to content

Make integration tests support windows 2022 #1999

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ DRIVERWINDOWSBINARY=${DRIVERBINARY}.exe
DOCKER=DOCKER_CLI_EXPERIMENTAL=enabled docker

BASE_IMAGE_LTSC2019=mcr.microsoft.com/windows/servercore:ltsc2019
BASE_IMAGE_LTSC2022=mcr.microsoft.com/windows/servercore:ltsc2022

# Both arrays MUST be index aligned.
WINDOWS_IMAGE_TAGS=ltsc2019
Expand Down Expand Up @@ -60,14 +61,20 @@ build-and-push-windows-container-ltsc2019: require-GCE_PD_CSI_STAGING_IMAGE init
--build-arg BASE_IMAGE=$(BASE_IMAGE_LTSC2019) \
--build-arg STAGINGVERSION=$(STAGINGVERSION) --push --provenance=false .

build-and-push-multi-arch: build-and-push-container-linux-amd64 build-and-push-container-linux-arm64 build-and-push-windows-container-ltsc2019
$(DOCKER) manifest create $(STAGINGIMAGE):$(STAGINGVERSION) $(STAGINGIMAGE):$(STAGINGVERSION)_linux_amd64 $(STAGINGIMAGE):$(STAGINGVERSION)_linux_arm64 $(STAGINGIMAGE):$(STAGINGVERSION)_ltsc2019
STAGINGIMAGE="$(STAGINGIMAGE)" STAGINGVERSION="$(STAGINGVERSION)" WINDOWS_IMAGE_TAGS="$(WINDOWS_IMAGE_TAGS)" WINDOWS_BASE_IMAGES="$(WINDOWS_BASE_IMAGES)" ./manifest_osversion.sh
build-and-push-windows-container-ltsc2022: require-GCE_PD_CSI_STAGING_IMAGE init-buildx
$(DOCKER) buildx build --file=Dockerfile.Windows --platform=windows/amd64 \
-t $(STAGINGIMAGE):$(STAGINGVERSION)_ltsc2022 \
--build-arg BASE_IMAGE=$(BASE_IMAGE_LTSC2022) \
--build-arg STAGINGVERSION=$(STAGINGVERSION) --push --provenance=false .

build-and-push-multi-arch: build-and-push-container-linux-amd64 build-and-push-container-linux-arm64 build-and-push-windows-container-ltsc2019 build-and-push-windows-container-ltsc2022
$(DOCKER) manifest create $(STAGINGIMAGE):$(STAGINGVERSION) $(STAGINGIMAGE):$(STAGINGVERSION)_linux_amd64 $(STAGINGIMAGE):$(STAGINGVERSION)_linux_arm64 $(STAGINGIMAGE):$(STAGINGVERSION)_ltsc2019 $(STAGINGIMAGE):$(STAGINGVERSION)_ltsc2022
STAGINGIMAGE="$(STAGINGIMAGE)" STAGINGVERSION="$(STAGINGVERSION)" WINDOWS_IMAGE_TAGS="ltsc2019, ltsc2022" WINDOWS_BASE_IMAGES="$(BASE_IMAGE_LTSC2019), $(BASE_IMAGE_LTSC2022)" ./manifest_osversion.sh
$(DOCKER) manifest push -p $(STAGINGIMAGE):$(STAGINGVERSION)

build-and-push-multi-arch-debug: build-and-push-container-linux-debug build-and-push-windows-container-ltsc2019
$(DOCKER) manifest create $(STAGINGIMAGE):$(STAGINGVERSION) $(STAGINGIMAGE):$(STAGINGVERSION)_linux $(STAGINGIMAGE):$(STAGINGVERSION)_ltsc2019
STAGINGIMAGE="$(STAGINGIMAGE)" STAGINGVERSION="$(STAGINGVERSION)" WINDOWS_IMAGE_TAGS="ltsc2019" WINDOWS_BASE_IMAGES="$(BASE_IMAGE_LTSC2019)" ./manifest_osversion.sh
build-and-push-multi-arch-debug: build-and-push-container-linux-debug build-and-push-windows-container-ltsc2019 build-and-push-windows-container-ltsc2022
$(DOCKER) manifest create $(STAGINGIMAGE):$(STAGINGVERSION) $(STAGINGIMAGE):$(STAGINGVERSION)_linux $(STAGINGIMAGE):$(STAGINGVERSION)_ltsc2019 $(STAGINGIMAGE):$(STAGINGVERSION)_ltsc2022
STAGINGIMAGE="$(STAGINGIMAGE)" STAGINGVERSION="$(STAGINGVERSION)" WINDOWS_IMAGE_TAGS="ltsc2019, ltsc2022" WINDOWS_BASE_IMAGES="$(BASE_IMAGE_LTSC2019), $(BASE_IMAGE_LTSC2022)" ./manifest_osversion.sh
$(DOCKER) manifest push -p $(STAGINGIMAGE):$(STAGINGVERSION)

push-container: build-container
Expand Down
15 changes: 14 additions & 1 deletion test/k8s-integration/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ func setImageTypeEnvs(imageType string) error {
case "cos":
case "cos_containerd":
case "gci": // GCI/COS is default type and does not need env vars set
case "win2019", "win2022":
// These are handled by the WINDOWS_NODE_OS_DISTRIBUTION env var and
// ingested in https://github.com/kubernetes/kubernetes/blob/ded2956c832502da8a0678f5392c24af1cc9dfc0/cluster/gce/util.sh#L112.
case "ubuntu", "ubuntu_containerd":
return errors.New("setting environment vars for bringing up *ubuntu* cluster on GCE is unimplemented")
/* TODO(dyzz) figure out how to bring up a Ubuntu cluster on GCE. The below doesn't work.
Expand Down Expand Up @@ -201,7 +204,17 @@ func clusterUpGKE(gceZone, gceRegion string, numNodes int, numWindowsNodes int,
var cmd *exec.Cmd
cmdParams := []string{"container", "clusters", "create", *gkeTestClusterName,
locationArg, locationVal, "--num-nodes", strconv.Itoa(numNodes),
"--quiet", "--machine-type", "n1-standard-2", "--image-type", imageType, "--no-enable-autoupgrade"}
"--quiet", "--machine-type", "n1-standard-2", "--no-enable-autoupgrade"}
if imageType == "win2019" || imageType == "win2022" {
cmdParams = append(cmdParams, "--image-type", "WINDOWS_LTSC_CONTAINERD")
if imageType == "win2019" {
cmdParams = append(cmdParams, "--windows-os-version", "ltsc2019")
} else {
cmdParams = append(cmdParams, "--windows-os-version", "ltsc2022")
}
} else {
cmdParams = append(cmdParams, "--image-type", imageType)
}
if isVariableSet(gkeClusterVer) {
cmdParams = append(cmdParams, "--cluster-version", *gkeClusterVer)
} else {
Expand Down
3 changes: 1 addition & 2 deletions test/k8s-integration/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func deleteDriver(testParams *testParameters, deployOverlayName string) error {
return nil
}

func pushImage(pkgDir, stagingImage, stagingVersion, platform string) error {
func pushImage(pkgDir, stagingImage, stagingVersion, platform, imageType string) error {
err := os.Setenv("GCE_PD_CSI_STAGING_VERSION", stagingVersion)
if err != nil {
return err
Expand All @@ -138,7 +138,6 @@ func pushImage(pkgDir, stagingImage, stagingVersion, platform string) error {
var cmd *exec.Cmd

if platform == "windows" {
// build multi-arch image which can work for both Linux and Windows
cmd = exec.Command("make", "-C", pkgDir, "build-and-push-multi-arch",
fmt.Sprintf("GCE_PD_CSI_STAGING_VERSION=%s", stagingVersion),
fmt.Sprintf("GCE_PD_CSI_STAGING_IMAGE=%s", stagingImage))
Expand Down
2 changes: 1 addition & 1 deletion test/k8s-integration/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func handle() error {
// Build and push the driver, if required. Defer the driver image deletion.
if *doDriverBuild {
klog.Infof("Building GCE PD CSI Driver")
err := pushImage(testParams.pkgDir, *stagingImage, testParams.stagingVersion, testParams.platform)
err := pushImage(testParams.pkgDir, *stagingImage, testParams.stagingVersion, testParams.platform, *imageType)
if err != nil {
return fmt.Errorf("failed pushing image: %v", err.Error())
}
Expand Down
9 changes: 8 additions & 1 deletion test/run-windows-k8s-integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ readonly test_version=${TEST_VERSION:-master}
readonly gce_zone=${GCE_CLUSTER_ZONE:-us-central1-b}
readonly use_kubetest2=${USE_KUBETEST2:-true}
readonly num_windows_nodes=${NUM_WINDOWS_NODES:-3}
readonly windows_distribution=${WINDOWS_NODE_OS_DISTRIBUTION:-win2019}

# build platforms for `make quick-release`
export KUBE_BUILD_PLATFORMS=${KUBE_BUILD_PLATFORMS:-"linux/amd64 windows/amd64"}
Expand All @@ -35,6 +36,11 @@ if [ "$use_kubetest2" = true ]; then
go install sigs.k8s.io/kubetest2/kubetest2-tester-ginkgo@${kt2_version}
fi

if [ "$windows_distribution" != "win2019" -a "$windows_distribution" != "win2022"]; then
print "Invalid windows distribution $windows_distribution provided. Exiting."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if [ "$windows_distribution" != "win2019" -a "$windows_distribution" != "win2022"]
print "Invalid windows distribution $windows_distribution provided. Exiting."
exit 1
fi

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦

exit 1
fi

${PKGDIR}/bin/k8s-integration-test \
--run-in-prow=true \
--service-account-file="${E2E_GOOGLE_APPLICATION_CREDENTIALS}" \
Expand All @@ -54,4 +60,5 @@ ${PKGDIR}/bin/k8s-integration-test \
--storageclass-files=sc-windows.yaml \
--snapshotclass-files=pd-volumesnapshotclass.yaml \
--test-focus='External.Storage' \
--use-kubetest2="${use_kubetest2}"
--use-kubetest2="${use_kubetest2}" \
--image-type="${windows_distribution}"