From 0cacc44fc94531a0824b6e3163ba428495fa3122 Mon Sep 17 00:00:00 2001 From: hasheddan Date: Mon, 11 May 2020 13:45:28 -0500 Subject: [PATCH] Retry resolving TCP address in agnhost/guestbook Currently the guestbook application will fail if unable to resolve TCP address on first attempt. If pod networking is not setup when the application starts then it will be unable to resolve, leading to frequent failures. This moves the address resolution into the retry block so it will try again if unsuccessful on first attempt. Signed-off-by: hasheddan --- test/images/agnhost/VERSION | 2 +- test/images/agnhost/agnhost.go | 2 +- test/images/agnhost/guestbook/guestbook.go | 12 +++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/test/images/agnhost/VERSION b/test/images/agnhost/VERSION index 6d28a11dd0e..5c6fb54899b 100644 --- a/test/images/agnhost/VERSION +++ b/test/images/agnhost/VERSION @@ -1 +1 @@ -2.16 +2.17 diff --git a/test/images/agnhost/agnhost.go b/test/images/agnhost/agnhost.go index bbad09a51b0..618cde93bd0 100644 --- a/test/images/agnhost/agnhost.go +++ b/test/images/agnhost/agnhost.go @@ -49,7 +49,7 @@ import ( ) func main() { - rootCmd := &cobra.Command{Use: "app", Version: "2.16"} + rootCmd := &cobra.Command{Use: "app", Version: "2.17"} rootCmd.AddCommand(auditproxy.CmdAuditProxy) rootCmd.AddCommand(connect.CmdConnect) diff --git a/test/images/agnhost/guestbook/guestbook.go b/test/images/agnhost/guestbook/guestbook.go index 9c63e44b307..ab783517dd5 100644 --- a/test/images/agnhost/guestbook/guestbook.go +++ b/test/images/agnhost/guestbook/guestbook.go @@ -77,16 +77,18 @@ func registerNode(registerTo, port string) { } hostPort := net.JoinHostPort(registerTo, backendPort) - _, err := net.ResolveTCPAddr("tcp", hostPort) - if err != nil { - log.Fatalf("--slaveof param and/or --backend-port param are invalid. %v", err) - return - } request := fmt.Sprintf("register?host=%s", getIP(hostPort).String()) log.Printf("Registering to master: %s/%s", hostPort, request) start := time.Now() for time.Since(start) < timeout { + _, err := net.ResolveTCPAddr("tcp", hostPort) + if err != nil { + log.Printf("--slaveof param and/or --backend-port param are invalid. %v. Retrying in 1 second.", err) + time.Sleep(sleep) + continue + } + response, err := dialHTTP(request, hostPort) if err != nil { log.Printf("encountered error while registering to master: %v. Retrying in 1 second.", err)