From 415fe230b4f6331a9e8b54692dcc514875d1fc46 Mon Sep 17 00:00:00 2001 From: jornshen Date: Fri, 29 Jan 2021 11:28:06 +0800 Subject: [PATCH] check externalNameService more time --- test/e2e/framework/service/jig.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/test/e2e/framework/service/jig.go b/test/e2e/framework/service/jig.go index 227c8721f9f..c48b0785caf 100644 --- a/test/e2e/framework/service/jig.go +++ b/test/e2e/framework/service/jig.go @@ -988,13 +988,16 @@ func (j *TestJig) checkExternalServiceReachability(svc *v1.Service, pod *v1.Pod) svcName := fmt.Sprintf("%s.%s.svc.%s", svc.Name, svc.Namespace, framework.TestContext.ClusterDNSDomain) // Service must resolve to IP cmd := fmt.Sprintf("nslookup %s", svcName) - _, stderr, err := framework.RunHostCmdWithFullOutput(pod.Namespace, pod.Name, cmd) - // NOTE(claudiub): nslookup may return 0 on Windows, even though the DNS name was not found. In this case, - // we can check stderr for the error. - if err != nil || (framework.NodeOSDistroIs("windows") && strings.Contains(stderr, fmt.Sprintf("can't find %s", svcName))) { - return fmt.Errorf("ExternalName service %q must resolve to IP", pod.Namespace+"/"+pod.Name) - } - return nil + return wait.PollImmediate(framework.Poll, ServiceReachabilityShortPollTimeout, func() (done bool, err error) { + _, stderr, err := framework.RunHostCmdWithFullOutput(pod.Namespace, pod.Name, cmd) + // NOTE(claudiub): nslookup may return 0 on Windows, even though the DNS name was not found. In this case, + // we can check stderr for the error. + if err != nil || (framework.NodeOSDistroIs("windows") && strings.Contains(stderr, fmt.Sprintf("can't find %s", svcName))) { + framework.Logf("ExternalName service %q failed to resolve to IP", pod.Namespace+"/"+pod.Name) + return false, nil + } + return true, nil + }) } // CheckServiceReachability ensures that request are served by the services. Only supports Services with type ClusterIP, NodePort and ExternalName.