Skip to content

Commit

Permalink
Merge pull request #11 from xiangli-cmu/master
Browse files Browse the repository at this point in the history
return error when cannot join the cluster
  • Loading branch information
xiang90 committed Jul 11, 2013
2 parents 01e5d41 + 931afb9 commit 78cb13c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,9 @@ func joinCluster(s *raft.Server, serverName string) error {
resp, err := t.Post(fmt.Sprintf("%s/join", serverName), &b)

for {
if err != nil {
return fmt.Errorf("Unable to join: %v", err)
}
if resp != nil {
defer resp.Body.Close()
if resp.StatusCode == http.StatusOK {
Expand Down
12 changes: 10 additions & 2 deletions transporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ func (t transporter) SendAppendEntriesRequest(server *raft.Server, peer *raft.Pe

debug("Send LogEntries to %s ", peer.Name())

resp, _ := t.Post(fmt.Sprintf("%s/log/append", peer.Name()), &b)
resp, err := t.Post(fmt.Sprintf("%s/log/append", peer.Name()), &b)

if err != nil {
debug("Cannot send AppendEntriesRequest to %s : %s", peer.Name(), err)
}

if resp != nil {
defer resp.Body.Close()
Expand All @@ -47,7 +51,11 @@ func (t transporter) SendVoteRequest(server *raft.Server, peer *raft.Peer, req *

debug("Send Vote to %s", peer.Name())

resp, _ := t.Post(fmt.Sprintf("%s/vote", peer.Name()), &b)
resp, err := t.Post(fmt.Sprintf("%s/vote", peer.Name()), &b)

if err != nil {
debug("Cannot send VoteRequest to %s : %s", peer.Name(), err)
}

if resp != nil {
defer resp.Body.Close()
Expand Down

0 comments on commit 78cb13c

Please sign in to comment.