1
0
Fork 0

Check join and notify addresses are resolvable

master
Philip O'Toole 10 months ago
parent 41fb5d5a1a
commit 70d5e6de34

@ -2136,16 +2136,6 @@ func executeRequestFromStrings(s []string, timings, tx bool) *command.ExecuteReq
}
}
func resolvableAddress(addr string) (string, error) {
h, _, err := net.SplitHostPort(addr)
if err != nil {
// Just try the given address directly.
h = addr
}
_, err = net.LookupHost(h)
return h, err
}
func makeCredentials(username, password string) *cluster.Credentials {
return &cluster.Credentials{
Username: username,

@ -1336,6 +1336,15 @@ func (s *Store) Notify(nr *command.NotifyRequest) error {
if _, ok := s.notifyingNodes[nr.Id]; ok {
return nil
}
// Confirm that this node can resolve the remote address. This can happen due
// to incomplete DNS records across the underlying infrastructure. If it can't
// then don't consider this Notify attempt successful -- so the notifying node
// will presumably try again.
if addr, err := resolvableAddress(nr.Address); err != nil {
return fmt.Errorf("failed to resolve %s: %w", addr, err)
}
s.notifyingNodes[nr.Id] = &Server{nr.Id, nr.Address, "voter"}
if len(s.notifyingNodes) < s.BootstrapExpect {
return nil
@ -1378,6 +1387,14 @@ func (s *Store) Join(jr *command.JoinRequest) error {
addr := jr.Address
voter := jr.Voter
// Confirm that this node can resolve the remote address. This can happen due
// to incomplete DNS records across the underlying infrastructure. If it can't
// then don't consider this join attempt successful -- so the joining node
// will presumably try again.
if addr, err := resolvableAddress(addr); err != nil {
return fmt.Errorf("failed to resolve %s: %w", addr, err)
}
configFuture := s.raft.GetConfiguration()
if err := configFuture.Error(); err != nil {
s.logger.Printf("failed to get raft configuration: %v", err)
@ -2233,3 +2250,13 @@ func fullPretty(full bool) string {
}
return "incremental"
}
func resolvableAddress(addr string) (string, error) {
h, _, err := net.SplitHostPort(addr)
if err != nil {
// Just try the given address directly.
h = addr
}
_, err = net.LookupHost(h)
return h, err
}

Loading…
Cancel
Save