From 47f7f4417dcfe550e2ac06342eaad28ed2525a76 Mon Sep 17 00:00:00 2001 From: Prashanth Balasubramanian Date: Tue, 2 Feb 2016 11:34:36 -0800 Subject: [PATCH] Poll w/ timeout for nodeport to disappear. --- test/e2e/service.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/test/e2e/service.go b/test/e2e/service.go index db60705247f..7cc12a86adb 100644 --- a/test/e2e/service.go +++ b/test/e2e/service.go @@ -42,7 +42,9 @@ import ( // Maximum time a kube-proxy daemon on a node is allowed to not // notice a Service update, such as type=NodePort. -const kubeProxyLagTimeout = 45 * time.Second +// TODO: This timeout should be O(10s), observed values are O(1m), 5m is very +// liberal. Fix tracked in #20567. +const kubeProxyLagTimeout = 5 * time.Minute // This should match whatever the default/configured range is var ServiceNodePortRange = utilnet.PortRange{Base: 30000, Size: 2768} @@ -769,9 +771,17 @@ var _ = Describe("Services", func() { hostExec := LaunchHostExecPod(f.Client, f.Namespace.Name, "hostexec") cmd := fmt.Sprintf(`! ss -ant46 'sport = :%d' | tail -n +2 | grep LISTEN`, nodePort) - stdout, err := RunHostCmd(hostExec.Namespace, hostExec.Name, cmd) - if err != nil { - Failf("expected node port (%d) to not be in use, stdout: %v", nodePort, stdout) + var stdout string + if pollErr := wait.PollImmediate(poll, kubeProxyLagTimeout, func() (bool, error) { + var err error + stdout, err = RunHostCmd(hostExec.Namespace, hostExec.Name, cmd) + if err != nil { + Logf("expected node port (%d) to not be in use, stdout: %v", nodePort, stdout) + return false, nil + } + return true, nil + }); pollErr != nil { + Failf("expected node port (%d) to not be in use in %v, stdout: %v", nodePort, kubeProxyLagTimeout, stdout) } By(fmt.Sprintf("creating service "+serviceName+" with same NodePort %d", nodePort))