{"action":"created","comment":{"url":"https://api.github.com/repos/coreos/etcd/pulls/comments/29273537","id":29273537,"diff_hunk":"@@ -106,3 +108,51 @@ func getRemotePeerURLs(cl ClusterInfo, local string) []string {\n \tsort.Strings(us)\n \treturn us\n }\n+\n+// getVersions returns the versions of the members in the given cluster.\n+// The key of the returned map is the member's ID. The value of the returned map\n+// is the semver version string. If it fails to get the version of a member, the key\n+// will be an empty string.\n+func getVersions(cl ClusterInfo, tr *http.Transport) map[string]string {\n+\tmembers := cl.Members()\n+\tvers := make(map[string]string)\n+\tfor _, m := range members {\n+\t\tver, err := getVersion(m, tr)\n+\t\tif err != nil {\n+\t\t\tlog.Printf(\"etcdserver: cannot get the version of member %s (%v)\", m.ID, err)\n+\t\t\tvers[m.ID.String()] = \"\"\n+\t\t} else {\n+\t\t\tvers[m.ID.String()] = ver\n+\t\t}\n+\t}\n+\treturn vers\n+}\n+\n+// decideVersion decides the cluster version based on the versions map.\n+// The returned version is the min version in the map, or nil if the min\n+// version in unknown.\n+func decideVersion(vers map[string]string) *semver.Version {\n+\tvar cv *semver.Version\n+\tlv := semver.Must(semver.NewVersion(version.Version))\n+\n+\tfor mid, ver := range vers {\n+\t\tif len(ver) == 0 {\n+\t\t\treturn nil\n+\t\t}\n+\t\tv, err := semver.NewVersion(ver)\n+\t\tif err != nil {\n+\t\t\tlog.Printf(\"etcdserver: cannot understand the version of member %s (%v)\", mid, err)\n+\t\t\treturn nil\n+\t\t}\n+\t\tif lv.LessThan(*v) {\n+\t\t\tlog.Printf(\"etcdserver: the etcd version %s is not up-to-date\", lv.String())\n+\t\t\tlog.Printf(\"etcdserver: member %s has a higher version %s\", mid, ver)\n+\t\t}","path":"etcdserver/cluster_util.go","position":53,"original_position":53,"commit_id":"f873171244847fe34f6ef9790509abb7df8a4bd8","original_commit_id":"34587b34446bc732292e3f0fe4c0db731dc38bd5","user":{"login":"yichengq","id":2976232,"avatar_url":"https://avatars.githubusercontent.com/u/2976232?v=3","gravatar_id":"","url":"https://api.github.com/users/yichengq","html_url":"https://github.com/yichengq","followers_url":"https://api.github.com/users/yichengq/followers","following_url":"https://api.github.com/users/yichengq/following{/other_user}","gists_url":"https://api.github.com/users/yichengq/gists{/gist_id}","starred_url":"https://api.github.com/users/yichengq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yichengq/subscriptions","organizations_url":"https://api.github.com/users/yichengq/orgs","repos_url":"https://api.github.com/users/yichengq/repos","events_url":"https://api.github.com/users/yichengq/events{/privacy}","received_events_url":"https://api.github.com/users/yichengq/received_events","type":"User","site_admin":false},"body":"I expect that the function only decides version using the version map. But it does one more thing that compare the peer version with its own and print out log if the peer one is higher.","created_at":"2015-04-28T18:32:43Z","updated_at":"2015-04-28T18:32:43Z","html_url":"https://github.com/coreos/etcd/pull/2718#discussion_r29273537","pull_request_url":"https://api.github.com/repos/coreos/etcd/pulls/2718","_links":{"self":{"href":"https://api.github.com/repos/coreos/etcd/pulls/comments/29273537"},"html":{"href":"https://github.com/coreos/etcd/pull/2718#discussion_r29273537"},"pull_request":{"href":"https://api.github.com/repos/coreos/etcd/pulls/2718"}}},"pull_request":{"url":"https://api.github.com/repos/coreos/etcd/pulls/2718","id":33727271,"html_url":"https://github.com/coreos/etcd/pull/2718","diff_url":"https://github.com/coreos/etcd/pull/2718.diff","patch_url":"https://github.com/coreos/etcd/pull/2718.patch","issue_url":"https://api.github.com/repos/coreos/etcd/issues/2718","number":2718,"state":"open","locked":false,"title":"support cluster-wide version sync","user":{"login":"xiang90","id":4479947,"avatar_url":"https://avatars.githubusercontent.com/u/4479947?v=3","gravatar_id":"","url":"https://api.github.com/users/xiang90","html_url":"https://github.com/xiang90","followers_url":"https://api.github.com/users/xiang90/followers","following_url":"https://api.github.com/users/xiang90/following{/other_user}","gists_url":"https://api.github.com/users/xiang90/gists{/gist_id}","starred_url":"https://api.github.com/users/xiang90/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiang90/subscriptions","organizations_url":"https://api.github.com/users/xiang90/orgs","repos_url":"https://api.github.com/users/xiang90/repos","events_url":"https://api.github.com/users/xiang90/events{/privacy}","received_events_url":"https://api.github.com/users/xiang90/received_events","type":"User","site_admin":false},"body":"etcdserver will start with MinVersion.\r\netcdsever periodically checks the versions of all the members.\r\nIt updates the cluster version to the min-version of all the members.   \r\n\r\nnext thing todo after this pr:\r\nwrite the synced version into wal through raft. so everybody can know the previous synced version even after restarting.\r\n\r\nRelated issues:\r\n1. check cluster version when joining the cluster\r\n2. check the cluster version when restarting\r\n3. check minVer and Version at runtime when receiving a raft message.","created_at":"2015-04-21T03:55:39Z","updated_at":"2015-04-28T18:32:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"488f6fe8dab2061becffe27e3329feb17dee0f35","assignee":null,"milestone":{"url":"https://api.github.com/repos/coreos/etcd/milestones/20","html_url":"https://github.com/coreos/etcd/milestones/v2.1.0-alpha.1","labels_url":"https://api.github.com/repos/coreos/etcd/milestones/20/labels","id":1082803,"number":20,"title":"v2.1.0-alpha.1","description":"","creator":{"login":"barakmich","id":98356,"avatar_url":"https://avatars.githubusercontent.com/u/98356?v=3","gravatar_id":"","url":"https://api.github.com/users/barakmich","html_url":"https://github.com/barakmich","followers_url":"https://api.github.com/users/barakmich/followers","following_url":"https://api.github.com/users/barakmich/following{/other_user}","gists_url":"https://api.github.com/users/barakmich/gists{/gist_id}","starred_url":"https://api.github.com/users/barakmich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/barakmich/subscriptions","organizations_url":"https://api.github.com/users/barakmich/orgs","repos_url":"https://api.github.com/users/barakmich/repos","events_url":"https://api.github.com/users/barakmich/events{/privacy}","received_events_url":"https://api.github.com/users/barakmich/received_events","type":"User","site_admin":false},"open_issues":10,"closed_issues":0,"state":"open","created_at":"2015-04-24T20:02:07Z","updated_at":"2015-04-27T23:04:32Z","due_on":"2016-04-06T04:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/coreos/etcd/pulls/2718/commits","review_comments_url":"https://api.github.com/repos/coreos/etcd/pulls/2718/comments","review_comment_url":"https://api.github.com/repos/coreos/etcd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/coreos/etcd/issues/2718/comments","statuses_url":"https://api.github.com/repos/coreos/etcd/statuses/f873171244847fe34f6ef9790509abb7df8a4bd8","head":{"label":"xiang90:version","ref":"version","sha":"f873171244847fe34f6ef9790509abb7df8a4bd8","user":{"login":"xiang90","id":4479947,"avatar_url":"https://avatars.githubusercontent.com/u/4479947?v=3","gravatar_id":"","url":"https://api.github.com/users/xiang90","html_url":"https://github.com/xiang90","followers_url":"https://api.github.com/users/xiang90/followers","following_url":"https://api.github.com/users/xiang90/following{/other_user}","gists_url":"https://api.github.com/users/xiang90/gists{/gist_id}","starred_url":"https://api.github.com/users/xiang90/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiang90/subscriptions","organizations_url":"https://api.github.com/users/xiang90/orgs","repos_url":"https://api.github.com/users/xiang90/repos","events_url":"https://api.github.com/users/xiang90/events{/privacy}","received_events_url":"https://api.github.com/users/xiang90/received_events","type":"User","site_admin":false},"repo":{"id":11245678,"name":"etcd","full_name":"xiang90/etcd","owner":{"login":"xiang90","id":4479947,"avatar_url":"https://avatars.githubusercontent.com/u/4479947?v=3","gravatar_id":"","url":"https://api.github.com/users/xiang90","html_url":"https://github.com/xiang90","followers_url":"https://api.github.com/users/xiang90/followers","following_url":"https://api.github.com/users/xiang90/following{/other_user}","gists_url":"https://api.github.com/users/xiang90/gists{/gist_id}","starred_url":"https://api.github.com/users/xiang90/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiang90/subscriptions","organizations_url":"https://api.github.com/users/xiang90/orgs","repos_url":"https://api.github.com/users/xiang90/repos","events_url":"https://api.github.com/users/xiang90/events{/privacy}","received_events_url":"https://api.github.com/users/xiang90/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/xiang90/etcd","description":null,"fork":true,"url":"https://api.github.com/repos/xiang90/etcd","forks_url":"https://api.github.com/repos/xiang90/etcd/forks","keys_url":"https://api.github.com/repos/xiang90/etcd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xiang90/etcd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xiang90/etcd/teams","hooks_url":"https://api.github.com/repos/xiang90/etcd/hooks","issue_events_url":"https://api.github.com/repos/xiang90/etcd/issues/events{/number}","events_url":"https://api.github.com/repos/xiang90/etcd/events","assignees_url":"https://api.github.com/repos/xiang90/etcd/assignees{/user}","branches_url":"https://api.github.com/repos/xiang90/etcd/branches{/branch}","tags_url":"https://api.github.com/repos/xiang90/etcd/tags","blobs_url":"https://api.github.com/repos/xiang90/etcd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xiang90/etcd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xiang90/etcd/git/refs{/sha}","trees_url":"https://api.github.com/repos/xiang90/etcd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xiang90/etcd/statuses/{sha}","languages_url":"https://api.github.com/repos/xiang90/etcd/languages","stargazers_url":"https://api.github.com/repos/xiang90/etcd/stargazers","contributors_url":"https://api.github.com/repos/xiang90/etcd/contributors","subscribers_url":"https://api.github.com/repos/xiang90/etcd/subscribers","subscription_url":"https://api.github.com/repos/xiang90/etcd/subscription","commits_url":"https://api.github.com/repos/xiang90/etcd/commits{/sha}","git_commits_url":"https://api.github.com/repos/xiang90/etcd/git/commits{/sha}","comments_url":"https://api.github.com/repos/xiang90/etcd/comments{/number}","issue_comment_url":"https://api.github.com/repos/xiang90/etcd/issues/comments{/number}","contents_url":"https://api.github.com/repos/xiang90/etcd/contents/{+path}","compare_url":"https://api.github.com/repos/xiang90/etcd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xiang90/etcd/merges","archive_url":"https://api.github.com/repos/xiang90/etcd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xiang90/etcd/downloads","issues_url":"https://api.github.com/repos/xiang90/etcd/issues{/number}","pulls_url":"https://api.github.com/repos/xiang90/etcd/pulls{/number}","milestones_url":"https://api.github.com/repos/xiang90/etcd/milestones{/number}","notifications_url":"https://api.github.com/repos/xiang90/etcd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xiang90/etcd/labels{/name}","releases_url":"https://api.github.com/repos/xiang90/etcd/releases{/id}","created_at":"2013-07-08T04:17:14Z","updated_at":"2014-12-15T22:29:22Z","pushed_at":"2015-04-28T18:10:50Z","git_url":"git://github.com/xiang90/etcd.git","ssh_url":"git@github.com:xiang90/etcd.git","clone_url":"https://github.com/xiang90/etcd.git","svn_url":"https://github.com/xiang90/etcd","homepage":null,"size":18952,"stargazers_count":4,"watchers_count":4,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":4,"default_branch":"master"}},"base":{"label":"coreos:master","ref":"master","sha":"0d6e062b5b9146df7489f044bc9a6ece96d4aa06","user":{"login":"coreos","id":3730757,"avatar_url":"https://avatars.githubusercontent.com/u/3730757?v=3","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"repo":{"id":11225014,"name":"etcd","full_name":"coreos/etcd","owner":{"login":"coreos","id":3730757,"avatar_url":"https://avatars.githubusercontent.com/u/3730757?v=3","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/coreos/etcd","description":"A highly-available key value store for shared configuration and service discovery","fork":false,"url":"https://api.github.com/repos/coreos/etcd","forks_url":"https://api.github.com/repos/coreos/etcd/forks","keys_url":"https://api.github.com/repos/coreos/etcd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coreos/etcd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coreos/etcd/teams","hooks_url":"https://api.github.com/repos/coreos/etcd/hooks","issue_events_url":"https://api.github.com/repos/coreos/etcd/issues/events{/number}","events_url":"https://api.github.com/repos/coreos/etcd/events","assignees_url":"https://api.github.com/repos/coreos/etcd/assignees{/user}","branches_url":"https://api.github.com/repos/coreos/etcd/branches{/branch}","tags_url":"https://api.github.com/repos/coreos/etcd/tags","blobs_url":"https://api.github.com/repos/coreos/etcd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coreos/etcd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coreos/etcd/git/refs{/sha}","trees_url":"https://api.github.com/repos/coreos/etcd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coreos/etcd/statuses/{sha}","languages_url":"https://api.github.com/repos/coreos/etcd/languages","stargazers_url":"https://api.github.com/repos/coreos/etcd/stargazers","contributors_url":"https://api.github.com/repos/coreos/etcd/contributors","subscribers_url":"https://api.github.com/repos/coreos/etcd/subscribers","subscription_url":"https://api.github.com/repos/coreos/etcd/subscription","commits_url":"https://api.github.com/repos/coreos/etcd/commits{/sha}","git_commits_url":"https://api.github.com/repos/coreos/etcd/git/commits{/sha}","comments_url":"https://api.github.com/repos/coreos/etcd/comments{/number}","issue_comment_url":"https://api.github.com/repos/coreos/etcd/issues/comments{/number}","contents_url":"https://api.github.com/repos/coreos/etcd/contents/{+path}","compare_url":"https://api.github.com/repos/coreos/etcd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coreos/etcd/merges","archive_url":"https://api.github.com/repos/coreos/etcd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coreos/etcd/downloads","issues_url":"https://api.github.com/repos/coreos/etcd/issues{/number}","pulls_url":"https://api.github.com/repos/coreos/etcd/pulls{/number}","milestones_url":"https://api.github.com/repos/coreos/etcd/milestones{/number}","notifications_url":"https://api.github.com/repos/coreos/etcd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coreos/etcd/labels{/name}","releases_url":"https://api.github.com/repos/coreos/etcd/releases{/id}","created_at":"2013-07-06T21:57:21Z","updated_at":"2015-04-28T14:46:45Z","pushed_at":"2015-04-28T18:17:55Z","git_url":"git://github.com/coreos/etcd.git","ssh_url":"git@github.com:coreos/etcd.git","clone_url":"https://github.com/coreos/etcd.git","svn_url":"https://github.com/coreos/etcd","homepage":"","size":32706,"stargazers_count":6288,"watchers_count":6288,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":791,"mirror_url":null,"open_issues_count":165,"forks":791,"open_issues":165,"watchers":6288,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/coreos/etcd/pulls/2718"},"html":{"href":"https://github.com/coreos/etcd/pull/2718"},"issue":{"href":"https://api.github.com/repos/coreos/etcd/issues/2718"},"comments":{"href":"https://api.github.com/repos/coreos/etcd/issues/2718/comments"},"review_comments":{"href":"https://api.github.com/repos/coreos/etcd/pulls/2718/comments"},"review_comment":{"href":"https://api.github.com/repos/coreos/etcd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/coreos/etcd/pulls/2718/commits"},"statuses":{"href":"https://api.github.com/repos/coreos/etcd/statuses/f873171244847fe34f6ef9790509abb7df8a4bd8"}}}}