Merge pull request #6147 from sinsharat/master

etcdserver: Error handling for invalid empty raft cluster
This commit is contained in:
Xiang Li 2016-08-10 08:52:45 -07:00 committed by GitHub
commit b6f5b6b1c9
2 changed files with 12 additions and 6 deletions

View File

@ -258,15 +258,12 @@ func startProxy(cfg *config) error {
clientURLs := []string{}
uf := func() []string {
gcls, gerr := etcdserver.GetClusterFromRemotePeers(peerURLs, tr)
// TODO: remove the 2nd check when we fix GetClusterFromRemotePeers
// GetClusterFromRemotePeers should not return nil error with an invalid empty cluster
if gerr != nil {
plog.Warningf("proxy: %v", gerr)
return []string{}
}
if len(gcls.Members()) == 0 {
return clientURLs
}
clientURLs = gcls.ClientURLs()
urls := struct{ PeerURLs []string }{gcls.PeerURLs()}

View File

@ -94,7 +94,16 @@ func getClusterFromRemotePeers(urls []string, timeout time.Duration, logerr bool
}
continue
}
return membership.NewClusterFromMembers("", id, membs), nil
// check the length of membership members
// if the membership members are present then prepare and return raft cluster
// if membership members are not present then the raft cluster formed will be
// an invalid empty cluster hence return failed to get raft cluster member(s) from the given urls error
if len(membs) > 0 {
return membership.NewClusterFromMembers("", id, membs), nil
}
return nil, fmt.Errorf("failed to get raft cluster member(s) from the given urls.")
}
return nil, fmt.Errorf("could not retrieve cluster information from the given urls")
}