Files
kubevirt/0015-tests-Delete-VMI-prior-to-NFS-server-pod.patch
Vasily Ulyanov af0885f309 Accepting request 1107890 from home:vulyanov:branches:Virtualization
- Delete VMI prior to NFS server pod in tests
  0015-tests-Delete-VMI-prior-to-NFS-server-pod.patch

OBS-URL: https://build.opensuse.org/request/show/1107890
OBS-URL: https://build.opensuse.org/package/show/Virtualization/kubevirt?expand=0&rev=133
2023-08-29 09:21:30 +00:00

148 lines
4.8 KiB
Diff

From 1d2feb4ac5ac5f26ccd4abf2270caf0599ae893c Mon Sep 17 00:00:00 2001
From: Vasiliy Ulyanov <vulyanov@suse.de>
Date: Mon, 21 Aug 2023 11:32:56 +0200
Subject: [PATCH 1/3] tests: Delete VMI prior to NFS server pod
Kubelet fails to umount the NFS volume and gets stuck when performing
pod cleanup if the server has already gone. Ensure that the VMI is
deleted first and the corresponding volume is released (current global
tests cleanup hook does not guarantee deletion order).
Signed-off-by: Vasiliy Ulyanov <vulyanov@suse.de>
---
tests/storage/storage.go | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tests/storage/storage.go b/tests/storage/storage.go
index 672ba2355..a4dfc3dd5 100644
--- a/tests/storage/storage.go
+++ b/tests/storage/storage.go
@@ -216,6 +216,11 @@ var _ = SIGDescribe("Storage", func() {
var pvName string
var nfsPod *k8sv1.Pod
AfterEach(func() {
+ // Ensure VMI is deleted before bringing down the NFS server
+ err = virtClient.VirtualMachineInstance(vmi.Namespace).Delete(context.Background(), vmi.Name, &metav1.DeleteOptions{})
+ Expect(err).ToNot(HaveOccurred(), failedDeleteVMI)
+ libwait.WaitForVirtualMachineToDisappearWithTimeout(vmi, 120)
+
if targetImagePath != testsuite.HostPathAlpine {
tests.DeleteAlpineWithNonQEMUPermissions()
}
--
2.41.0
From 029cb1fd6fee273f5b43615674d8c54143a3ef47 Mon Sep 17 00:00:00 2001
From: Vasiliy Ulyanov <vulyanov@suse.de>
Date: Wed, 23 Aug 2023 14:41:57 +0200
Subject: [PATCH 2/3] tests: Delete AlpineWithNonQEMUPermissions image
Previously the disk image was not deleted because targetImagePath was
not set properly. The condition in AfterEach was never positive:
if targetImagePath != testsuite.HostPathAlpine {
tests.DeleteAlpineWithNonQEMUPermissions()
}
Signed-off-by: Vasiliy Ulyanov <vulyanov@suse.de>
---
tests/storage/storage.go | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/tests/storage/storage.go b/tests/storage/storage.go
index a4dfc3dd5..90bb6e871 100644
--- a/tests/storage/storage.go
+++ b/tests/storage/storage.go
@@ -231,11 +231,10 @@ var _ = SIGDescribe("Storage", func() {
var nodeName string
// Start the VirtualMachineInstance with the PVC attached
if storageEngine == "nfs" {
- targetImage := targetImagePath
if !imageOwnedByQEMU {
- targetImage, nodeName = tests.CopyAlpineWithNonQEMUPermissions()
+ targetImagePath, nodeName = tests.CopyAlpineWithNonQEMUPermissions()
}
- nfsPod = storageframework.InitNFS(targetImage, nodeName)
+ nfsPod = storageframework.InitNFS(targetImagePath, nodeName)
pvName = createNFSPvAndPvc(family, nfsPod)
} else {
pvName = tests.DiskAlpineHostPath
--
2.41.0
From ca0be7fc564ce755d3e88c6f0ea6afcfc32b60b7 Mon Sep 17 00:00:00 2001
From: Vasiliy Ulyanov <vulyanov@suse.de>
Date: Thu, 24 Aug 2023 11:34:47 +0200
Subject: [PATCH 3/3] Hack nfs-server image to run it 'graceless'
The NFS grace period is set to 90 seconds and it stalls the clients
trying to access the share right after the server start. This may affect
the tests and lead to timeouts so disable the setting.
Signed-off-by: Vasiliy Ulyanov <vulyanov@suse.de>
---
images/nfs-server/BUILD.bazel | 12 ++++++++++++
images/nfs-server/entrypoint.sh | 12 ++++++++++++
2 files changed, 24 insertions(+)
create mode 100644 images/nfs-server/entrypoint.sh
diff --git a/images/nfs-server/BUILD.bazel b/images/nfs-server/BUILD.bazel
index 343d72cf1..8494fcac5 100644
--- a/images/nfs-server/BUILD.bazel
+++ b/images/nfs-server/BUILD.bazel
@@ -2,6 +2,14 @@ load(
"@io_bazel_rules_docker//container:container.bzl",
"container_image",
)
+load("@rules_pkg//:pkg.bzl", "pkg_tar")
+
+pkg_tar(
+ name = "entrypoint",
+ srcs = [":entrypoint.sh"],
+ mode = "0775",
+ package_dir = "/",
+)
container_image(
name = "nfs-server-image",
@@ -13,6 +21,7 @@ container_image(
"@io_bazel_rules_go//go/platform:linux_arm64": "@nfs-server_aarch64//image",
"//conditions:default": "@nfs-server//image",
}),
+ cmd = ["/entrypoint.sh"],
ports = [
"111/udp",
"2049/udp",
@@ -25,5 +34,8 @@ container_image(
"32766/tcp",
"32767/tcp",
],
+ tars = [
+ ":entrypoint",
+ ],
visibility = ["//visibility:public"],
)
diff --git a/images/nfs-server/entrypoint.sh b/images/nfs-server/entrypoint.sh
new file mode 100644
index 000000000..aa40154cd
--- /dev/null
+++ b/images/nfs-server/entrypoint.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+set -euxo pipefail
+
+# The NFS grace period is set to 90 seconds and it stalls the clients
+# trying to access the share right after the server start. This may affect
+# the tests and lead to timeouts so disable the setting.
+sed -i"" \
+ -e "s#Grace_Period = 90#Graceless = true#g" \
+ /opt/start_nfs.sh
+
+exec /opt/start_nfs.sh
--
2.41.0