From f092343300f9aa628b1166550f7764aff48e20ee Mon Sep 17 00:00:00 2001 From: Ionut Balutoiu Date: Thu, 3 Nov 2022 17:33:31 +0200 Subject: [PATCH] tests: Spawn poststart / prestop pods on the same node as the https pod In the PR https://github.com/kubernetes/kubernetes/pull/86139, two more lifecycle hook tests (poststart / prestop) were added using HTTPS. They are similar with the existing HTTP tests. However, this causes failures on Windows due to how networking works there. We previously fixed this in the HTTP tests via https://github.com/kubernetes/kubernetes/commit/f9e4a015e223b1076f61accda48583d92aa3ea33. This commit applies the same fix on the lifecycle hook HTTPS tests. Signed-off-by: Ionut Balutoiu --- test/e2e/common/node/lifecycle_hook.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/e2e/common/node/lifecycle_hook.go b/test/e2e/common/node/lifecycle_hook.go index cb041447439..6acc72b90a7 100644 --- a/test/e2e/common/node/lifecycle_hook.go +++ b/test/e2e/common/node/lifecycle_hook.go @@ -184,7 +184,7 @@ var _ = SIGDescribe("Container Lifecycle Hook", func() { /* Release : v1.23 Testname: Pod Lifecycle, poststart https hook - Description: When a post-start handler is specified in the container lifecycle using a 'HttpGet' action, then the handler MUST be invoked before the container is terminated. A server pod is created that will serve https requests, create a second pod with a container lifecycle specifying a post-start that invokes the server pod to validate that the post-start is executed. + Description: When a post-start handler is specified in the container lifecycle using a 'HttpGet' action, then the handler MUST be invoked before the container is terminated. A server pod is created that will serve https requests, create a second pod on the same node with a container lifecycle specifying a post-start that invokes the server pod to validate that the post-start is executed. */ ginkgo.It("should execute poststart https hook properly [MinimumKubeletVersion:1.23] [NodeConformance]", func() { lifecycle := &v1.Lifecycle{ @@ -198,6 +198,10 @@ var _ = SIGDescribe("Container Lifecycle Hook", func() { }, } podWithHook := getPodWithHook("pod-with-poststart-https-hook", imageutils.GetPauseImageName(), lifecycle) + // make sure we spawn the test pod on the same node as the webserver. + nodeSelection := e2epod.NodeSelection{} + e2epod.SetAffinity(&nodeSelection, targetNode) + e2epod.SetNodeSelection(&podWithHook.Spec, nodeSelection) testPodWithHook(podWithHook) }) /* @@ -225,7 +229,7 @@ var _ = SIGDescribe("Container Lifecycle Hook", func() { /* Release : v1.23 Testname: Pod Lifecycle, prestop https hook - Description: When a pre-stop handler is specified in the container lifecycle using a 'HttpGet' action, then the handler MUST be invoked before the container is terminated. A server pod is created that will serve https requests, create a second pod with a container lifecycle specifying a pre-stop that invokes the server pod to validate that the pre-stop is executed. + Description: When a pre-stop handler is specified in the container lifecycle using a 'HttpGet' action, then the handler MUST be invoked before the container is terminated. A server pod is created that will serve https requests, create a second pod on the same node with a container lifecycle specifying a pre-stop that invokes the server pod to validate that the pre-stop is executed. */ ginkgo.It("should execute prestop https hook properly [MinimumKubeletVersion:1.23] [NodeConformance]", func() { lifecycle := &v1.Lifecycle{ @@ -239,6 +243,10 @@ var _ = SIGDescribe("Container Lifecycle Hook", func() { }, } podWithHook := getPodWithHook("pod-with-prestop-https-hook", imageutils.GetPauseImageName(), lifecycle) + // make sure we spawn the test pod on the same node as the webserver. + nodeSelection := e2epod.NodeSelection{} + e2epod.SetAffinity(&nodeSelection, targetNode) + e2epod.SetNodeSelection(&podWithHook.Spec, nodeSelection) testPodWithHook(podWithHook) }) })