From 919f3a34cd9b0ab14be47b9c01fafd3b0c215bc2 Mon Sep 17 00:00:00 2001 From: Ray Bejjani Date: Tue, 7 Apr 2020 10:55:34 +0200 Subject: [PATCH] CI: K8sFQDNTest retry initial DNS lookups We target jenkins.cilium.io and vagrant-cache.ci.cilium.io as the remote targets for the FQDN tests. Sometimes, the DNS lookups fail and so does the test. We now retry for 30 seconds. When your DNS lookup at first doesn't succeed, try try again. Signed-off-by: Ray Bejjani --- test/k8sT/fqdn.go | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/test/k8sT/fqdn.go b/test/k8sT/fqdn.go index 017fe56b6d8d..da90659313a5 100644 --- a/test/k8sT/fqdn.go +++ b/test/k8sT/fqdn.go @@ -45,14 +45,27 @@ var _ = Describe("K8sFQDNTest", func() { ) BeforeAll(func() { - // In case the IPs changed, update them here - addrs, err := net.LookupHost("vagrant-cache.ci.cilium.io") - Expect(err).Should(BeNil(), "Error getting IPs for test") - worldTargetIP = addrs[0] - - addrs, err = net.LookupHost("jenkins.cilium.io") - Expect(err).Should(BeNil(), "Error getting IPs for test") - worldInvalidTargetIP = addrs[0] + // In case the IPs changed from above, update them here + var lookupErr error + err := helpers.WithTimeout(func() bool { + var addrs []string + addrs, lookupErr = net.LookupHost("vagrant-cache.ci.cilium.io") + if lookupErr != nil { + lookupErr = fmt.Errorf("error looking up vagrant-cache.ci.cilium.io: %s", lookupErr) + return false + } + worldTargetIP = addrs[0] + + addrs, lookupErr = net.LookupHost("jenkins.cilium.io") + if lookupErr != nil { + lookupErr = fmt.Errorf("error looking up jenkins.cilium.io: %s", lookupErr) + return false + } + worldInvalidTargetIP = addrs[0] + + return true + }, "Could not get vagrant-cache.ci.cilium.io and jenkins.cilium.io IPs", &helpers.TimeoutConfig{Timeout: helpers.MidCommandTimeout}) + Expect(err).Should(BeNil(), "Error obtaining IPs for test: %s", lookupErr) kubectl = helpers.CreateKubectl(helpers.K8s1VMName(), logger) demoManifest = helpers.ManifestGet(kubectl.BasePath(), "demo.yaml")