GitHub PullRequestReviewCommentEvent at 2014-05-07 05:43:14
Repository: etcd
Actor: philips
Payload: {"comment":{"url":"https://api.github.com/repos/coreos/etcd/pulls/comments/12362176","id":12362176,"diff_hunk":"@@ -498,120 +547,105 @@ func (s *PeerServer) removeSelfFromList(peers []string) []string {\n \t// Remove its own peer address from the peer list to join\n \tu, err := url.Parse(s.Config.URL)\n \tif err != nil {\n-\t\tlog.Fatalf(\"removeSelfFromList cannot parse peer address %v\", s.Config.URL)\n+\t\tlog.Warnf(\"failed parsing self peer address %v\", s.Config.URL)\n+\t\tu = nil\n \t}\n \tnewPeers := make([]string, 0)\n \tfor _, v := range peers {\n-\t\tif v != u.Host {\n+\t\tif u == nil || v != u.Host {\n \t\t\tnewPeers = append(newPeers, v)\n \t\t}\n \t}\n \treturn newPeers\n }\n \n-func (s *PeerServer) joinCluster(cluster []string) bool {\n+func (s *PeerServer) joinCluster(cluster []string) (error, error) {\n \tfor _, peer := range cluster {\n \t\tif len(peer) == 0 {\n \t\t\tcontinue\n \t\t}\n \n-\t\terr := s.joinByPeer(s.raftServer, peer, s.Config.Scheme)\n-\t\tif err == nil {\n-\t\t\tlog.Debugf(\"%s joined the cluster via peer %s\", s.Config.Name, peer)\n-\t\t\treturn true\n-\n+\t\tjoinErr, err := s.joinByPeer(s.raftServer, peer, s.Config.Scheme)\n+\t\tif err != nil {\n+\t\t\tlog.Infof(\"%s attempted to join via %s failed: %s\", s.Config.Name, peer, err)\n+\t\t\tcontinue\n \t\t}\n \n-\t\tif _, ok := err.(etcdErr.Error); ok {\n-\t\t\tlog.Fatal(err)\n+\t\tif joinErr != nil {\n+\t\t\tlog.Infof(\"%s is rejected by the cluster via peer %s: %s\", s.Config.Name, peer, joinErr)\n+\t\t\treturn joinErr, nil\n \t\t}\n-\n-\t\tlog.Warnf(\"Attempt to join via %s failed: %s\", peer, err)\n+\t\tlog.Infof(\"%s joined the cluster via peer %s\", s.Config.Name, peer)\n+\t\treturn nil, nil\n \t}\n \n-\treturn false\n+\treturn nil, fmt.Errorf(\"unreachable cluster\")\n }\n \n // Send join requests to peer.\n-func (s *PeerServer) joinByPeer(server raft.Server, peer string, scheme string) error {\n-\t// t must be ok\n-\tt, _ := server.Transporter().(*transporter)\n+// The first return is why it is rejected by the cluster, the second one\n+// specifies the error in communication.\n+func (s *PeerServer) joinByPeer(server raft.Server, peer string, scheme string) (error, error) {\n+\tu := (&url.URL{Host: peer, Scheme: scheme}).String()\n \n \t// Our version must match the leaders version\n-\tversionURL := url.URL{Host: peer, Scheme: scheme, Path: \"/version\"}\n-\tversion, err := getVersion(t, versionURL)\n+\tversion, err := s.client.GetVersion(u)\n \tif err != nil {\n-\t\treturn fmt.Errorf(\"Error during join version check: %v\", err)\n+\t\tlog.Debugf(\"fail checking join version\")\n+\t\treturn nil, err","path":"server/peer_server.go","position":660,"original_position":660,"commit_id":"87deaca3d4676861b69390c5502ab563842ade8b","original_commit_id":"87deaca3d4676861b69390c5502ab563842ade8b","user":{"login":"philips","id":33544,"avatar_url":"https://avatars.githubusercontent.com/u/33544?","gravatar_id":"2786cdedd6e0eaa34b64b17e1cea81b9","url":"https://api.github.com/users/philips","html_url":"https://github.com/philips","followers_url":"https://api.github.com/users/philips/followers","following_url":"https://api.github.com/users/philips/following{/other_user}","gists_url":"https://api.github.com/users/philips/gists{/gist_id}","starred_url":"https://api.github.com/users/philips/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philips/subscriptions","organizations_url":"https://api.github.com/users/philips/orgs","repos_url":"https://api.github.com/users/philips/repos","events_url":"https://api.github.com/users/philips/events{/privacy}","received_events_url":"https://api.github.com/users/philips/received_events","type":"User","site_admin":false},"body":"The fmt.Errorf is helplful here. Why is it changed?","created_at":"2014-05-07T05:43:14Z","updated_at":"2014-05-07T05:43:14Z","html_url":"https://github.com/coreos/etcd/pull/764#discussion_r12362176","pull_request_url":"https://api.github.com/repos/coreos/etcd/pulls/764","_links":{"self":{"href":"https://api.github.com/repos/coreos/etcd/pulls/comments/12362176"},"html":{"href":"https://github.com/coreos/etcd/pull/764#discussion_r12362176"},"pull_request":{"href":"https://api.github.com/repos/coreos/etcd/pulls/764"}}}}