mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
fix join command
This commit is contained in:
parent
bbf78b076a
commit
84624f1ec0
8
etcd.go
8
etcd.go
@ -17,7 +17,6 @@ import (
|
||||
"net/url"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path"
|
||||
"runtime/pprof"
|
||||
"strings"
|
||||
"time"
|
||||
@ -624,15 +623,10 @@ func joinCluster(s *raft.Server, serverName string) error {
|
||||
|
||||
address := resp.Header.Get("Location")
|
||||
debugf("Send Join Request to %s", address)
|
||||
u, err := url.Parse(address)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to join: %s", err.Error())
|
||||
}
|
||||
|
||||
json.NewEncoder(&b).Encode(command)
|
||||
|
||||
resp, err = t.Post(path.Join(u.Host, u.Path), &b)
|
||||
resp, err = t.Post(address, &b)
|
||||
|
||||
} else if resp.StatusCode == http.StatusBadRequest {
|
||||
debug("Reach max number machines in the cluster")
|
||||
|
@ -106,7 +106,7 @@ func DeleteHttpHandler(w *http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
|
||||
// Dispatch the command to leader
|
||||
func dispatch(c Command, w *http.ResponseWriter, req *http.Request, client bool) {
|
||||
func dispatch(c Command, w *http.ResponseWriter, req *http.Request, etcd bool) {
|
||||
if raftServer.State() == "leader" {
|
||||
if body, err := raftServer.Do(c); err != nil {
|
||||
if _, ok := err.(store.NotFoundError); ok {
|
||||
@ -170,11 +170,12 @@ func dispatch(c Command, w *http.ResponseWriter, req *http.Request, client bool)
|
||||
|
||||
var url string
|
||||
|
||||
if client {
|
||||
clientAddr, _ := getEtcdURL(raftServer.Leader())
|
||||
url = clientAddr + path
|
||||
if etcd {
|
||||
etcdAddr, _ := nameToEtcdURL(raftServer.Leader())
|
||||
url = etcdAddr + path
|
||||
} else {
|
||||
url = raftServer.Leader() + path
|
||||
raftAddr, _ := nameToRaftURL(raftServer.Leader())
|
||||
url = raftAddr + path
|
||||
}
|
||||
|
||||
debugf("Redirect to %s", url)
|
||||
|
Loading…
x
Reference in New Issue
Block a user