mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
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 <georgedanielmangum@gmail.com>
This commit is contained in:
parent
9b44fa4a07
commit
0cacc44fc9
@ -1 +1 @@
|
||||
2.16
|
||||
2.17
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user