|
|
|
@ -4,6 +4,7 @@ import (
|
|
|
|
|
"bytes"
|
|
|
|
|
"crypto/tls"
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"errors"
|
|
|
|
|
"fmt"
|
|
|
|
|
"io/ioutil"
|
|
|
|
|
"log"
|
|
|
|
@ -16,6 +17,11 @@ import (
|
|
|
|
|
httpd "github.com/rqlite/rqlite/http"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
// ErrJoinFailed is returned when a node fails to join a cluster
|
|
|
|
|
ErrJoinFailed = errors.New("failed to join cluster")
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Join attempts to join the cluster at one of the addresses given in joinAddr.
|
|
|
|
|
// It walks through joinAddr in order, and sets the node ID and Raft address of
|
|
|
|
|
// the joining node as id addr respectively. It returns the endpoint successfully
|
|
|
|
@ -41,7 +47,7 @@ func Join(joinAddr []string, id, addr string, voter bool, meta map[string]string
|
|
|
|
|
time.Sleep(attemptInterval)
|
|
|
|
|
}
|
|
|
|
|
logger.Printf("failed to join cluster at %s, after %d attempts", joinAddr, numAttempts)
|
|
|
|
|
return "", err
|
|
|
|
|
return "", ErrJoinFailed
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func join(joinAddr, id, addr string, voter bool, meta map[string]string, tlsConfig *tls.Config, logger *log.Logger) (string, error) {
|
|
|
|
|