Skip to content
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

e2e test fix: Wait longer when first creating ELB #44696

Merged
merged 1 commit into from
Apr 20, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/e2e/framework/networking_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 17 additions & 8 deletions test/e2e/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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())
Expand All @@ -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
Expand All @@ -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)
})
})

Expand Down