From df043d747cc52992d10aca4adfd13edbf382c16d Mon Sep 17 00:00:00 2001 From: Tiernan Date: Sat, 3 Sep 2022 05:13:03 +1000 Subject: [PATCH] Fix error handling in Client consulDiscoveryImpl (#14431) Added a missing `continue` on non-nil error to avoid accidentally using a bad peer. --- .changelog/14431.txt | 3 +++ client/client.go | 1 + 2 files changed, 4 insertions(+) create mode 100644 .changelog/14431.txt diff --git a/.changelog/14431.txt b/.changelog/14431.txt new file mode 100644 index 00000000000..f6a1a7a5065 --- /dev/null +++ b/.changelog/14431.txt @@ -0,0 +1,3 @@ +```release-note:bug +client: Fixed bug where clients could attempt to connect to servers with invalid addresses retrieved from Consul. +``` diff --git a/client/client.go b/client/client.go index d7fed868258..3f4042b3303 100644 --- a/client/client.go +++ b/client/client.go @@ -2869,6 +2869,7 @@ DISCOLOOP: addr, err := net.ResolveTCPAddr("tcp", p) if err != nil { mErr.Errors = append(mErr.Errors, err) + continue } srv := &servers.Server{Addr: addr} nomadServers = append(nomadServers, srv)