From 854900c4a1747cd392d577679c6c7365de06fc05 Mon Sep 17 00:00:00 2001 From: Justin Santa Barbara Date: Wed, 19 Apr 2017 22:10:15 -0400 Subject: [PATCH] e2e test fix: Wait longer when first creating ELB On any cloud (GCE or AWS), a lag between creating the LoadBalancer and having it actually start serving traffic is expected. On AWS the lag is larger, and we weren't correctly using the longer wait on our first request. Use a longer wait period on our first request. Fix #44695 --- test/e2e/framework/networking_utils.go | 4 ++-- test/e2e/service.go | 25 +++++++++++++++++-------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/test/e2e/framework/networking_utils.go b/test/e2e/framework/networking_utils.go index 97caf32b078..c62260eae2d 100644 --- a/test/e2e/framework/networking_utils.go +++ b/test/e2e/framework/networking_utils.go @@ -594,9 +594,9 @@ func (config *NetworkingTestConfig) getNamespacesClient() coreclientset.Namespac return config.f.ClientSet.Core().Namespaces() } -func CheckReachabilityFromPod(expectToBeReachable bool, namespace, pod, target string) { +func CheckReachabilityFromPod(expectToBeReachable bool, timeout time.Duration, namespace, pod, target string) { cmd := fmt.Sprintf("wget -T 5 -qO- %q", target) - err := wait.PollImmediate(Poll, 2*time.Minute, func() (bool, error) { + err := wait.PollImmediate(Poll, timeout, func() (bool, error) { _, err := RunHostCmd(namespace, pod, cmd) if expectToBeReachable && err != nil { Logf("Expect target to be reachable. But got err: %v. Retry until timeout", err) diff --git a/test/e2e/service.go b/test/e2e/service.go index 3a915f6ed4f..558fb8a56da 100644 --- a/test/e2e/service.go +++ b/test/e2e/service.go @@ -1167,6 +1167,10 @@ var _ = framework.KubeDescribe("Services", func() { // this feature currently supported only on GCE/GKE/AWS framework.SkipUnlessProviderIs("gce", "gke", "aws") + loadBalancerLagTimeout := framework.LoadBalancerLagTimeoutDefault + if framework.ProviderIs("aws") { + loadBalancerLagTimeout = framework.LoadBalancerLagTimeoutAWS + } loadBalancerCreateTimeout := framework.LoadBalancerCreateTimeoutDefault if nodes := framework.GetReadySchedulableNodesOrDie(cs); len(nodes.Items) > framework.LargeClusterMinNodesNumber { loadBalancerCreateTimeout = framework.LoadBalancerCreateTimeoutLarge @@ -1182,7 +1186,7 @@ var _ = framework.KubeDescribe("Services", func() { acceptPodName := framework.CreateExecPodOrFail(cs, namespace, "execpod-accept", nil) dropPodName := framework.CreateExecPodOrFail(cs, namespace, "execpod-drop", nil) - accpetPod, err := cs.Core().Pods(namespace).Get(acceptPodName, metav1.GetOptions{}) + acceptPod, err := cs.Core().Pods(namespace).Get(acceptPodName, metav1.GetOptions{}) Expect(err).NotTo(HaveOccurred()) dropPod, err := cs.Core().Pods(namespace).Get(dropPodName, metav1.GetOptions{}) Expect(err).NotTo(HaveOccurred()) @@ -1194,7 +1198,7 @@ var _ = framework.KubeDescribe("Services", func() { // Create loadbalancer service with source range from node[0] and podAccept svc := jig.CreateTCPServiceOrFail(namespace, func(svc *v1.Service) { svc.Spec.Type = v1.ServiceTypeLoadBalancer - svc.Spec.LoadBalancerSourceRanges = []string{accpetPod.Status.PodIP + "/32"} + svc.Spec.LoadBalancerSourceRanges = []string{acceptPod.Status.PodIP + "/32"} }) // Clean up loadbalancer service @@ -1209,25 +1213,30 @@ var _ = framework.KubeDescribe("Services", func() { svc = jig.WaitForLoadBalancerOrFail(namespace, serviceName, loadBalancerCreateTimeout) jig.SanityCheckService(svc, v1.ServiceTypeLoadBalancer) + // timeout when we haven't just created the load balancer + normalReachabilityTimeout := 2 * time.Minute + By("check reachability from different sources") svcIP := framework.GetIngressPoint(&svc.Status.LoadBalancer.Ingress[0]) - framework.CheckReachabilityFromPod(true, namespace, acceptPodName, svcIP) - framework.CheckReachabilityFromPod(false, namespace, dropPodName, svcIP) + // Wait longer as this is our first request after creation. We can't check using a separate method, + // because the LB should only be reachable from the "accept" pod + framework.CheckReachabilityFromPod(true, loadBalancerLagTimeout, namespace, acceptPodName, svcIP) + framework.CheckReachabilityFromPod(false, normalReachabilityTimeout, namespace, dropPodName, svcIP) By("Update service LoadBalancerSourceRange and check reachability") jig.UpdateServiceOrFail(svc.Namespace, svc.Name, func(svc *v1.Service) { // only allow access from dropPod svc.Spec.LoadBalancerSourceRanges = []string{dropPod.Status.PodIP + "/32"} }) - framework.CheckReachabilityFromPod(false, namespace, acceptPodName, svcIP) - framework.CheckReachabilityFromPod(true, namespace, dropPodName, svcIP) + framework.CheckReachabilityFromPod(false, normalReachabilityTimeout, namespace, acceptPodName, svcIP) + framework.CheckReachabilityFromPod(true, normalReachabilityTimeout, namespace, dropPodName, svcIP) By("Delete LoadBalancerSourceRange field and check reachability") jig.UpdateServiceOrFail(svc.Namespace, svc.Name, func(svc *v1.Service) { svc.Spec.LoadBalancerSourceRanges = nil }) - framework.CheckReachabilityFromPod(true, namespace, acceptPodName, svcIP) - framework.CheckReachabilityFromPod(true, namespace, dropPodName, svcIP) + framework.CheckReachabilityFromPod(true, normalReachabilityTimeout, namespace, acceptPodName, svcIP) + framework.CheckReachabilityFromPod(true, normalReachabilityTimeout, namespace, dropPodName, svcIP) }) })