Skip to content

Commit

Permalink
Merge pull request #98521 from JornShen/check_externalNameService_mor…
Browse files Browse the repository at this point in the history
…e_time

check externalNameService more time
  • Loading branch information
k8s-ci-robot committed Jan 30, 2021
2 parents 2c395ef + 415fe23 commit 61e9ffb
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions test/e2e/framework/service/jig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 61e9ffb

Please sign in to comment.