diff --git a/test/e2e/windows/hybrid_network.go b/test/e2e/windows/hybrid_network.go index e2d05a3ec3c..df9c8fabaaa 100644 --- a/test/e2e/windows/hybrid_network.go +++ b/test/e2e/windows/hybrid_network.go @@ -69,10 +69,10 @@ var _ = sigDescribe("Hybrid cluster network", skipUnlessWindows(func() { ginkgo.By("verifying pod internal connectivity to the cluster dataplane") ginkgo.By("checking connectivity from Linux to Windows") - assertConsistentConnectivity(ctx, f, linuxPod.ObjectMeta.Name, linuxOS, linuxCheck(windowsPod.Status.PodIP, 80)) + assertConsistentConnectivity(ctx, f, linuxPod.ObjectMeta.Name, linuxOS, linuxCheck(windowsPod.Status.PodIP, 80), internalMaxTries) ginkgo.By("checking connectivity from Windows to Linux") - assertConsistentConnectivity(ctx, f, windowsPod.ObjectMeta.Name, windowsOS, windowsCheck(linuxPod.Status.PodIP)) + assertConsistentConnectivity(ctx, f, windowsPod.ObjectMeta.Name, windowsOS, windowsCheck(linuxPod.Status.PodIP), internalMaxTries) }) @@ -84,7 +84,7 @@ var _ = sigDescribe("Hybrid cluster network", skipUnlessWindows(func() { ginkgo.By("verifying pod external connectivity to the internet") ginkgo.By("checking connectivity to 8.8.8.8 53 (google.com) from Linux") - assertConsistentConnectivity(ctx, f, linuxPod.ObjectMeta.Name, linuxOS, linuxCheck("8.8.8.8", 53)) + assertConsistentConnectivity(ctx, f, linuxPod.ObjectMeta.Name, linuxOS, linuxCheck("8.8.8.8", 53), externalMaxTries) }) ginkgo.It("should provide Internet connection for Windows containers using DNS [Feature:Networking-DNS]", func(ctx context.Context) { @@ -95,7 +95,7 @@ var _ = sigDescribe("Hybrid cluster network", skipUnlessWindows(func() { ginkgo.By("verifying pod external connectivity to the internet") ginkgo.By("checking connectivity to 8.8.8.8 53 (google.com) from Windows") - assertConsistentConnectivity(ctx, f, windowsPod.ObjectMeta.Name, windowsOS, windowsCheck("www.google.com")) + assertConsistentConnectivity(ctx, f, windowsPod.ObjectMeta.Name, windowsOS, windowsCheck("www.google.com"), externalMaxTries) }) }) @@ -106,14 +106,20 @@ var ( duration = "10s" pollInterval = "1s" timeoutSeconds = 10 + + externalMaxTries = 10 + internalMaxTries = 1 ) -func assertConsistentConnectivity(ctx context.Context, f *framework.Framework, podName string, os string, cmd []string) { +func assertConsistentConnectivity(ctx context.Context, f *framework.Framework, podName string, os string, cmd []string, maxTries int) { connChecker := func() error { - ginkgo.By(fmt.Sprintf("checking connectivity of %s-container in %s", os, podName)) - // TODO, we should be retrying this similar to what is done in DialFromNode, in the test/e2e/networking/networking.go tests - stdout, stderr, err := e2epod.ExecCommandInContainerWithFullOutput(f, podName, os+"-container", cmd...) - if err != nil { + var err error + for i := 0; i < maxTries; i++ { + ginkgo.By(fmt.Sprintf("checking connectivity of %s-container in %s", os, podName)) + stdout, stderr, err := e2epod.ExecCommandInContainerWithFullOutput(f, podName, os+"-container", cmd...) + if err == nil { + break + } framework.Logf("Encountered error while running command: %v.\nStdout: %s\nStderr: %s\nErr: %v", cmd, stdout, stderr, err) } return err diff --git a/test/e2e/windows/reboot_node.go b/test/e2e/windows/reboot_node.go index a1b7790f60f..67beb4a4bd1 100644 --- a/test/e2e/windows/reboot_node.go +++ b/test/e2e/windows/reboot_node.go @@ -111,13 +111,13 @@ var _ = sigDescribe("[Feature:Windows] [Excluded:WindowsDocker] [MinimumKubeletV nginxPod = e2epod.NewPodClient(f).CreateSync(ctx, nginxPod) ginkgo.By("checking connectivity to 8.8.8.8 53 (google.com) from Linux") - assertConsistentConnectivity(ctx, f, nginxPod.ObjectMeta.Name, "linux", linuxCheck("8.8.8.8", 53)) + assertConsistentConnectivity(ctx, f, nginxPod.ObjectMeta.Name, "linux", linuxCheck("8.8.8.8", 53), externalMaxTries) ginkgo.By("checking connectivity to www.google.com from Windows") - assertConsistentConnectivity(ctx, f, agnPod.ObjectMeta.Name, "windows", windowsCheck("www.google.com")) + assertConsistentConnectivity(ctx, f, agnPod.ObjectMeta.Name, "windows", windowsCheck("www.google.com"), externalMaxTries) ginkgo.By("checking connectivity from Linux to Windows for the first time") - assertConsistentConnectivity(ctx, f, nginxPod.ObjectMeta.Name, "linux", linuxCheck(agnPod.Status.PodIP, 80)) + assertConsistentConnectivity(ctx, f, nginxPod.ObjectMeta.Name, "linux", linuxCheck(agnPod.Status.PodIP, 80), internalMaxTries) initialRestartCount := podutil.GetExistingContainerStatus(agnPod.Status.ContainerStatuses, "windows-container").RestartCount @@ -201,7 +201,7 @@ var _ = sigDescribe("[Feature:Windows] [Excluded:WindowsDocker] [MinimumKubeletV agnPodOut, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Get(ctx, agnPod.Name, metav1.GetOptions{}) gomega.Expect(agnPodOut.Status.Phase).To(gomega.Equal(v1.PodRunning)) framework.ExpectNoError(err, "getting pod info after reboot") - assertConsistentConnectivity(ctx, f, nginxPod.ObjectMeta.Name, "linux", linuxCheck(agnPodOut.Status.PodIP, 80)) + assertConsistentConnectivity(ctx, f, nginxPod.ObjectMeta.Name, "linux", linuxCheck(agnPodOut.Status.PodIP, 80), internalMaxTries) // create another host process pod to check system boot time checkPod := &v1.Pod{ diff --git a/test/e2e/windows/service.go b/test/e2e/windows/service.go index e7c431e2598..9a2e53b5dba 100644 --- a/test/e2e/windows/service.go +++ b/test/e2e/windows/service.go @@ -82,7 +82,7 @@ var _ = sigDescribe("Services", skipUnlessWindows(func() { // Admission controllers may sometimes do the wrong thing gomega.Expect(testPod.Spec.NodeSelector).To(gomega.HaveKeyWithValue("kubernetes.io/os", "windows"), "pod.spec.nodeSelector") ginkgo.By(fmt.Sprintf("checking connectivity Pod to curl http://%s:%d", nodeIP, nodePort)) - assertConsistentConnectivity(ctx, f, testPod.ObjectMeta.Name, windowsOS, windowsCheck(fmt.Sprintf("http://%s", net.JoinHostPort(nodeIP, strconv.Itoa(nodePort))))) + assertConsistentConnectivity(ctx, f, testPod.ObjectMeta.Name, windowsOS, windowsCheck(fmt.Sprintf("http://%s", net.JoinHostPort(nodeIP, strconv.Itoa(nodePort)))), internalMaxTries) }) }))