{"action":"created","comment":{"url":"https://api.github.com/repos/coreos/etcd-operator/pulls/comments/88141886","pull_request_review_id":8724737,"id":88141886,"diff_hunk":"@@ -0,0 +1,112 @@\n+// Copyright 2016 The etcd-operator Authors\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+//     http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+package cluster\n+\n+import (\n+\t\"fmt\"\n+\t\"time\"\n+\n+\t\"github.com/coreos/etcd-operator/pkg/util/constants\"\n+\t\"github.com/coreos/etcd-operator/pkg/util/k8sutil\"\n+\t\"github.com/coreos/etcd/clientv3\"\n+\t\"github.com/pborman/uuid\"\n+)\n+\n+func (c *Cluster) addOneSelfHostedMember() error {\n+\tnewMemberName := fmt.Sprintf(\"%s-%04d\", c.name, c.idCounter)\n+\tpeerURL := \"http://$(MY_POD_IP):2380\"\n+\tinitialCluster := append(c.members.PeerURLPairs(), newMemberName+\"=\"+peerURL)\n+\n+\tpod := k8sutil.MakeSelfHostedEtcdPod(newMemberName, initialCluster, c.name, \"existing\", \"\", c.spec)\n+\tpod = k8sutil.PodWithAddMemberInitContainer(pod, c.members.ClientURLs(), newMemberName, []string{peerURL}, c.spec)\n+\n+\t_, err := c.kclient.Pods(c.namespace).Create(pod)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\tc.idCounter++\n+\n+\t// wait for the new pod to start and add itself into the etcd cluster.\n+\tcfg := clientv3.Config{\n+\t\tEndpoints:   c.members.ClientURLs(),\n+\t\tDialTimeout: constants.DefaultDialTimeout,\n+\t}\n+\tetcdcli, err := clientv3.New(cfg)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\tdefer etcdcli.Close()\n+\n+\toldN := c.members.Size()\n+\t// TODO: do not wait forever.\n+\tfor {\n+\t\terr = c.updateMembers(etcdcli)\n+\t\t// TODO: check error type to determine the etcd member is not ready.\n+\t\tif err != nil && c.members != nil {\n+\t\t\tc.logger.Errorf(\"failed to list members for update: %v\", err)\n+\t\t\treturn err\n+\t\t}\n+\t\tif c.members.Size() > oldN {\n+\t\t\tbreak\n+\t\t}\n+\t\ttime.Sleep(5 * time.Second)\n+\t}\n+\n+\tc.logger.Infof(\"added a self-hosted member (%s)\", newMemberName)\n+\treturn nil\n+}\n+\n+func (c *Cluster) newSelfHostedSeedMember() error {\n+\tnewMemberName := fmt.Sprintf(\"%s-%04d\", c.name, c.idCounter)\n+\tinitialCluster := []string{newMemberName + \"=http://$(MY_POD_IP):2380\"}\n+\n+\tpod := k8sutil.MakeSelfHostedEtcdPod(newMemberName, initialCluster, c.name, \"new\", uuid.New(), c.spec)\n+\terr := k8sutil.CreateAndWaitPod(c.kclient, c.namespace, pod, 30*time.Second)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\tc.idCounter++","path":"pkg/cluster/self_hosted.go","position":80,"original_position":80,"commit_id":"a44f1fb9a71b60318f73f22bfb5d4baf28b087b6","original_commit_id":"a44f1fb9a71b60318f73f22bfb5d4baf28b087b6","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":"right. will fix.","created_at":"2016-11-15T23:57:04Z","updated_at":"2016-11-15T23:57:04Z","html_url":"https://github.com/coreos/etcd-operator/pull/366#discussion_r88141886","pull_request_url":"https://api.github.com/repos/coreos/etcd-operator/pulls/366","_links":{"self":{"href":"https://api.github.com/repos/coreos/etcd-operator/pulls/comments/88141886"},"html":{"href":"https://github.com/coreos/etcd-operator/pull/366#discussion_r88141886"},"pull_request":{"href":"https://api.github.com/repos/coreos/etcd-operator/pulls/366"}}},"pull_request":{"url":"https://api.github.com/repos/coreos/etcd-operator/pulls/366","id":93711680,"html_url":"https://github.com/coreos/etcd-operator/pull/366","diff_url":"https://github.com/coreos/etcd-operator/pull/366.diff","patch_url":"https://github.com/coreos/etcd-operator/pull/366.patch","issue_url":"https://api.github.com/repos/coreos/etcd-operator/issues/366","number":366,"state":"open","locked":false,"title":"Support self hosted cluster","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":"1. use host network\r\n2. enable anti-affinity","created_at":"2016-11-15T07:08:48Z","updated_at":"2016-11-15T23:57:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"34daab1ef838411dcc060c39c43cb85936132940","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/coreos/etcd-operator/pulls/366/commits","review_comments_url":"https://api.github.com/repos/coreos/etcd-operator/pulls/366/comments","review_comment_url":"https://api.github.com/repos/coreos/etcd-operator/pulls/comments{/number}","comments_url":"https://api.github.com/repos/coreos/etcd-operator/issues/366/comments","statuses_url":"https://api.github.com/repos/coreos/etcd-operator/statuses/a44f1fb9a71b60318f73f22bfb5d4baf28b087b6","head":{"label":"coreos:hostnet","ref":"hostnet","sha":"a44f1fb9a71b60318f73f22bfb5d4baf28b087b6","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":64974719,"name":"etcd-operator","full_name":"coreos/etcd-operator","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-operator","description":"etcd Operator creates/configures/manages etcd clusters atop Kubernetes","fork":false,"url":"https://api.github.com/repos/coreos/etcd-operator","forks_url":"https://api.github.com/repos/coreos/etcd-operator/forks","keys_url":"https://api.github.com/repos/coreos/etcd-operator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coreos/etcd-operator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coreos/etcd-operator/teams","hooks_url":"https://api.github.com/repos/coreos/etcd-operator/hooks","issue_events_url":"https://api.github.com/repos/coreos/etcd-operator/issues/events{/number}","events_url":"https://api.github.com/repos/coreos/etcd-operator/events","assignees_url":"https://api.github.com/repos/coreos/etcd-operator/assignees{/user}","branches_url":"https://api.github.com/repos/coreos/etcd-operator/branches{/branch}","tags_url":"https://api.github.com/repos/coreos/etcd-operator/tags","blobs_url":"https://api.github.com/repos/coreos/etcd-operator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coreos/etcd-operator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coreos/etcd-operator/git/refs{/sha}","trees_url":"https://api.github.com/repos/coreos/etcd-operator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coreos/etcd-operator/statuses/{sha}","languages_url":"https://api.github.com/repos/coreos/etcd-operator/languages","stargazers_url":"https://api.github.com/repos/coreos/etcd-operator/stargazers","contributors_url":"https://api.github.com/repos/coreos/etcd-operator/contributors","subscribers_url":"https://api.github.com/repos/coreos/etcd-operator/subscribers","subscription_url":"https://api.github.com/repos/coreos/etcd-operator/subscription","commits_url":"https://api.github.com/repos/coreos/etcd-operator/commits{/sha}","git_commits_url":"https://api.github.com/repos/coreos/etcd-operator/git/commits{/sha}","comments_url":"https://api.github.com/repos/coreos/etcd-operator/comments{/number}","issue_comment_url":"https://api.github.com/repos/coreos/etcd-operator/issues/comments{/number}","contents_url":"https://api.github.com/repos/coreos/etcd-operator/contents/{+path}","compare_url":"https://api.github.com/repos/coreos/etcd-operator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coreos/etcd-operator/merges","archive_url":"https://api.github.com/repos/coreos/etcd-operator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coreos/etcd-operator/downloads","issues_url":"https://api.github.com/repos/coreos/etcd-operator/issues{/number}","pulls_url":"https://api.github.com/repos/coreos/etcd-operator/pulls{/number}","milestones_url":"https://api.github.com/repos/coreos/etcd-operator/milestones{/number}","notifications_url":"https://api.github.com/repos/coreos/etcd-operator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coreos/etcd-operator/labels{/name}","releases_url":"https://api.github.com/repos/coreos/etcd-operator/releases{/id}","deployments_url":"https://api.github.com/repos/coreos/etcd-operator/deployments","created_at":"2016-08-04T23:54:58Z","updated_at":"2016-11-15T23:46:07Z","pushed_at":"2016-11-15T21:19:29Z","git_url":"git://github.com/coreos/etcd-operator.git","ssh_url":"git@github.com:coreos/etcd-operator.git","clone_url":"https://github.com/coreos/etcd-operator.git","svn_url":"https://github.com/coreos/etcd-operator","homepage":"https://coreos.com/blog/introducing-the-etcd-operator.html","size":546,"stargazers_count":109,"watchers_count":109,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":22,"forks":8,"open_issues":22,"watchers":109,"default_branch":"master"}},"base":{"label":"coreos:master","ref":"master","sha":"a8a0e07b2385155305267787d2f1d6b8d30f548c","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":64974719,"name":"etcd-operator","full_name":"coreos/etcd-operator","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-operator","description":"etcd Operator creates/configures/manages etcd clusters atop Kubernetes","fork":false,"url":"https://api.github.com/repos/coreos/etcd-operator","forks_url":"https://api.github.com/repos/coreos/etcd-operator/forks","keys_url":"https://api.github.com/repos/coreos/etcd-operator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coreos/etcd-operator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coreos/etcd-operator/teams","hooks_url":"https://api.github.com/repos/coreos/etcd-operator/hooks","issue_events_url":"https://api.github.com/repos/coreos/etcd-operator/issues/events{/number}","events_url":"https://api.github.com/repos/coreos/etcd-operator/events","assignees_url":"https://api.github.com/repos/coreos/etcd-operator/assignees{/user}","branches_url":"https://api.github.com/repos/coreos/etcd-operator/branches{/branch}","tags_url":"https://api.github.com/repos/coreos/etcd-operator/tags","blobs_url":"https://api.github.com/repos/coreos/etcd-operator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coreos/etcd-operator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coreos/etcd-operator/git/refs{/sha}","trees_url":"https://api.github.com/repos/coreos/etcd-operator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coreos/etcd-operator/statuses/{sha}","languages_url":"https://api.github.com/repos/coreos/etcd-operator/languages","stargazers_url":"https://api.github.com/repos/coreos/etcd-operator/stargazers","contributors_url":"https://api.github.com/repos/coreos/etcd-operator/contributors","subscribers_url":"https://api.github.com/repos/coreos/etcd-operator/subscribers","subscription_url":"https://api.github.com/repos/coreos/etcd-operator/subscription","commits_url":"https://api.github.com/repos/coreos/etcd-operator/commits{/sha}","git_commits_url":"https://api.github.com/repos/coreos/etcd-operator/git/commits{/sha}","comments_url":"https://api.github.com/repos/coreos/etcd-operator/comments{/number}","issue_comment_url":"https://api.github.com/repos/coreos/etcd-operator/issues/comments{/number}","contents_url":"https://api.github.com/repos/coreos/etcd-operator/contents/{+path}","compare_url":"https://api.github.com/repos/coreos/etcd-operator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coreos/etcd-operator/merges","archive_url":"https://api.github.com/repos/coreos/etcd-operator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coreos/etcd-operator/downloads","issues_url":"https://api.github.com/repos/coreos/etcd-operator/issues{/number}","pulls_url":"https://api.github.com/repos/coreos/etcd-operator/pulls{/number}","milestones_url":"https://api.github.com/repos/coreos/etcd-operator/milestones{/number}","notifications_url":"https://api.github.com/repos/coreos/etcd-operator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coreos/etcd-operator/labels{/name}","releases_url":"https://api.github.com/repos/coreos/etcd-operator/releases{/id}","deployments_url":"https://api.github.com/repos/coreos/etcd-operator/deployments","created_at":"2016-08-04T23:54:58Z","updated_at":"2016-11-15T23:46:07Z","pushed_at":"2016-11-15T21:19:29Z","git_url":"git://github.com/coreos/etcd-operator.git","ssh_url":"git@github.com:coreos/etcd-operator.git","clone_url":"https://github.com/coreos/etcd-operator.git","svn_url":"https://github.com/coreos/etcd-operator","homepage":"https://coreos.com/blog/introducing-the-etcd-operator.html","size":546,"stargazers_count":109,"watchers_count":109,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":22,"forks":8,"open_issues":22,"watchers":109,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/coreos/etcd-operator/pulls/366"},"html":{"href":"https://github.com/coreos/etcd-operator/pull/366"},"issue":{"href":"https://api.github.com/repos/coreos/etcd-operator/issues/366"},"comments":{"href":"https://api.github.com/repos/coreos/etcd-operator/issues/366/comments"},"review_comments":{"href":"https://api.github.com/repos/coreos/etcd-operator/pulls/366/comments"},"review_comment":{"href":"https://api.github.com/repos/coreos/etcd-operator/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/coreos/etcd-operator/pulls/366/commits"},"statuses":{"href":"https://api.github.com/repos/coreos/etcd-operator/statuses/a44f1fb9a71b60318f73f22bfb5d4baf28b087b6"}}}}
{"actor":{"display_login":"xiang90"}}