|
|
|
@ -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
|
|
|
|
|
}
|
|
|
|
|