{"action":"created","comment":{"url":"https://api.github.com/repos/alibaba/pouch/pulls/comments/186353149","pull_request_review_id":117912828,"id":186353149,"diff_hunk":"@@ -166,3 +185,125 @@ func (c *Client) Version(ctx context.Context) (containerd.Version, error) {\n \n \treturn cli.client.Version(ctx)\n }\n+\n+func (c *Client) runContainerdDaemon(homeDir string, copts clientOpts) error {\n+\tif homeDir == \"\" {\n+\t\treturn fmt.Errorf(\"ctrd: containerd home dir should not be empty\")\n+\t}\n+\n+\tcontainerdPath, err := exec.LookPath(copts.containerdBinary)\n+\tif err != nil {\n+\t\treturn fmt.Errorf(\"failed to find containerd binary %s: %v\", copts.containerdBinary, err)\n+\t}\n+\n+\tpidFileName := path.Join(homeDir, \"containerd/state\", containerdPidFileName)\n+\tf, err := os.OpenFile(pidFileName, os.O_RDWR|os.O_CREATE, 0600)\n+\tdefer f.Close()\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\n+\tbuf := make([]byte, 8)\n+\tnum, err := f.Read(buf)\n+\tif err != nil && err != io.EOF {\n+\t\treturn err\n+\t}\n+\n+\tif num > 0 {\n+\t\tpid, err := strconv.ParseUint(string(buf[:num]), 10, 64)\n+\t\tif err != nil {\n+\t\t\treturn err\n+\t\t}\n+\t\tif utils.IsProcessAlive(int(pid)) {\n+\t\t\tlogrus.Infof(\"ctrd: previous instance of containerd still alive (%d)\", pid)\n+\t\t\tc.daemonPid = int(pid)\n+\t\t\treturn nil\n+\t\t}\n+\t}\n+\n+\t// empty container pid file\n+\t_, err = f.Seek(0, os.SEEK_SET)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\n+\tif err := f.Truncate(0); err != nil {\n+\t\treturn err\n+\t}\n+\n+\t// if socket file exists, delete it.\n+\tif _, err := os.Stat(c.socketPath); err == nil {\n+\t\tos.RemoveAll(c.socketPath)\n+\t}\n+\n+\t// Start a new containerd instance\n+\targs := []string{\n+\t\t\"-a\", copts.rpcAddr,\n+\t\t\"--root\", path.Join(homeDir, \"containerd/root\"),\n+\t\t\"--state\", path.Join(homeDir, \"containerd/state\"),\n+\t\t\"-l\", utils.If(copts.debugLog, \"debug\", \"info\").(string),\n+\t}\n+\n+\tcmd := exec.Command(containerdPath, args...)\n+\tcmd.Stdout = os.Stdout\n+\tcmd.Stderr = os.Stderr\n+\tcmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true, Pdeathsig: syscall.SIGKILL}\n+\tcmd.Env = nil\n+\t// clear the NOTIFY_SOCKET from the env when starting containerd\n+\tfor _, e := range os.Environ() {\n+\t\tif !strings.HasPrefix(e, \"NOTIFY_SOCKET\") {\n+\t\t\tcmd.Env = append(cmd.Env, e)\n+\t\t}\n+\t}\n+\n+\tif err := cmd.Start(); err != nil {\n+\t\treturn err\n+\t}\n+\tlogrus.Infof(\"ctrd: new containerd process, pid: %d\", cmd.Process.Pid)\n+\n+\tif err := utils.SetOOMScore(cmd.Process.Pid, -17); err != nil {","path":"ctrd/client.go","position":202,"original_position":202,"commit_id":"58c1400984a4c4493f7274d0a3c6aeefa1b93eac","original_commit_id":"58c1400984a4c4493f7274d0a3c6aeefa1b93eac","user":{"login":"fuweid","id":17510957,"avatar_url":"https://avatars3.githubusercontent.com/u/17510957?v=4","gravatar_id":"","url":"https://api.github.com/users/fuweid","html_url":"https://github.com/fuweid","followers_url":"https://api.github.com/users/fuweid/followers","following_url":"https://api.github.com/users/fuweid/following{/other_user}","gists_url":"https://api.github.com/users/fuweid/gists{/gist_id}","starred_url":"https://api.github.com/users/fuweid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fuweid/subscriptions","organizations_url":"https://api.github.com/users/fuweid/orgs","repos_url":"https://api.github.com/users/fuweid/repos","events_url":"https://api.github.com/users/fuweid/events{/privacy}","received_events_url":"https://api.github.com/users/fuweid/received_events","type":"User","site_admin":false},"body":"I remember the `containerd` has the OOM score settings in the configuration. In my opinion, it's better if we maintain configuration for the pouchd. The configuration can help us to locate the problem in the future. How do you think?\r\n","created_at":"2018-05-07T08:02:44Z","updated_at":"2018-05-07T08:02:48Z","html_url":"https://github.com/alibaba/pouch/pull/1275#discussion_r186353149","pull_request_url":"https://api.github.com/repos/alibaba/pouch/pulls/1275","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/alibaba/pouch/pulls/comments/186353149"},"html":{"href":"https://github.com/alibaba/pouch/pull/1275#discussion_r186353149"},"pull_request":{"href":"https://api.github.com/repos/alibaba/pouch/pulls/1275"}}},"pull_request":{"url":"https://api.github.com/repos/alibaba/pouch/pulls/1275","id":186265157,"html_url":"https://github.com/alibaba/pouch/pull/1275","diff_url":"https://github.com/alibaba/pouch/pull/1275.diff","patch_url":"https://github.com/alibaba/pouch/pull/1275.patch","issue_url":"https://api.github.com/repos/alibaba/pouch/issues/1275","number":1275,"state":"open","locked":false,"title":"feature: take over old containerd instance when pouchd restart","user":{"login":"HusterWan","id":10414039,"avatar_url":"https://avatars3.githubusercontent.com/u/10414039?v=4","gravatar_id":"","url":"https://api.github.com/users/HusterWan","html_url":"https://github.com/HusterWan","followers_url":"https://api.github.com/users/HusterWan/followers","following_url":"https://api.github.com/users/HusterWan/following{/other_user}","gists_url":"https://api.github.com/users/HusterWan/gists{/gist_id}","starred_url":"https://api.github.com/users/HusterWan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HusterWan/subscriptions","organizations_url":"https://api.github.com/users/HusterWan/orgs","repos_url":"https://api.github.com/users/HusterWan/repos","events_url":"https://api.github.com/users/HusterWan/events{/privacy}","received_events_url":"https://api.github.com/users/HusterWan/received_events","type":"User","site_admin":false},"body":"Signed-off-by: Michael Wan <zirenwan@gmail.com>\r\n\r\n### Ⅰ. Describe what this PR did\r\nWhen `pouchd` restart, if old `containerd` is alive, we take it over.\r\n\r\n### Ⅱ. Does this pull request fix one issue?\r\n\r\n\r\n\r\n### Ⅲ. Describe how you did it\r\n\r\n\r\n### Ⅳ. Describe how to verify it\r\n\r\n\r\n### Ⅴ. Special notes for reviews\r\n\r\n\r\n","created_at":"2018-05-07T06:25:09Z","updated_at":"2018-05-07T08:02:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"65e9c2b8142157cd0fcd312ea8a67dc841763928","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":722348097,"url":"https://api.github.com/repos/alibaba/pouch/labels/kind/feature","name":"kind/feature","color":"1d76db","default":false},{"id":722355278,"url":"https://api.github.com/repos/alibaba/pouch/labels/size/XL","name":"size/XL","color":"f4abdb","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/alibaba/pouch/pulls/1275/commits","review_comments_url":"https://api.github.com/repos/alibaba/pouch/pulls/1275/comments","review_comment_url":"https://api.github.com/repos/alibaba/pouch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alibaba/pouch/issues/1275/comments","statuses_url":"https://api.github.com/repos/alibaba/pouch/statuses/58c1400984a4c4493f7274d0a3c6aeefa1b93eac","head":{"label":"HusterWan:zr/containerd-dev","ref":"zr/containerd-dev","sha":"58c1400984a4c4493f7274d0a3c6aeefa1b93eac","user":{"login":"HusterWan","id":10414039,"avatar_url":"https://avatars3.githubusercontent.com/u/10414039?v=4","gravatar_id":"","url":"https://api.github.com/users/HusterWan","html_url":"https://github.com/HusterWan","followers_url":"https://api.github.com/users/HusterWan/followers","following_url":"https://api.github.com/users/HusterWan/following{/other_user}","gists_url":"https://api.github.com/users/HusterWan/gists{/gist_id}","starred_url":"https://api.github.com/users/HusterWan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HusterWan/subscriptions","organizations_url":"https://api.github.com/users/HusterWan/orgs","repos_url":"https://api.github.com/users/HusterWan/repos","events_url":"https://api.github.com/users/HusterWan/events{/privacy}","received_events_url":"https://api.github.com/users/HusterWan/received_events","type":"User","site_admin":false},"repo":{"id":111375578,"name":"pouch","full_name":"HusterWan/pouch","owner":{"login":"HusterWan","id":10414039,"avatar_url":"https://avatars3.githubusercontent.com/u/10414039?v=4","gravatar_id":"","url":"https://api.github.com/users/HusterWan","html_url":"https://github.com/HusterWan","followers_url":"https://api.github.com/users/HusterWan/followers","following_url":"https://api.github.com/users/HusterWan/following{/other_user}","gists_url":"https://api.github.com/users/HusterWan/gists{/gist_id}","starred_url":"https://api.github.com/users/HusterWan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HusterWan/subscriptions","organizations_url":"https://api.github.com/users/HusterWan/orgs","repos_url":"https://api.github.com/users/HusterWan/repos","events_url":"https://api.github.com/users/HusterWan/events{/privacy}","received_events_url":"https://api.github.com/users/HusterWan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/HusterWan/pouch","description":"Pouch is an open-source project created to promote the container technology movement.","fork":true,"url":"https://api.github.com/repos/HusterWan/pouch","forks_url":"https://api.github.com/repos/HusterWan/pouch/forks","keys_url":"https://api.github.com/repos/HusterWan/pouch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/HusterWan/pouch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/HusterWan/pouch/teams","hooks_url":"https://api.github.com/repos/HusterWan/pouch/hooks","issue_events_url":"https://api.github.com/repos/HusterWan/pouch/issues/events{/number}","events_url":"https://api.github.com/repos/HusterWan/pouch/events","assignees_url":"https://api.github.com/repos/HusterWan/pouch/assignees{/user}","branches_url":"https://api.github.com/repos/HusterWan/pouch/branches{/branch}","tags_url":"https://api.github.com/repos/HusterWan/pouch/tags","blobs_url":"https://api.github.com/repos/HusterWan/pouch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/HusterWan/pouch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/HusterWan/pouch/git/refs{/sha}","trees_url":"https://api.github.com/repos/HusterWan/pouch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/HusterWan/pouch/statuses/{sha}","languages_url":"https://api.github.com/repos/HusterWan/pouch/languages","stargazers_url":"https://api.github.com/repos/HusterWan/pouch/stargazers","contributors_url":"https://api.github.com/repos/HusterWan/pouch/contributors","subscribers_url":"https://api.github.com/repos/HusterWan/pouch/subscribers","subscription_url":"https://api.github.com/repos/HusterWan/pouch/subscription","commits_url":"https://api.github.com/repos/HusterWan/pouch/commits{/sha}","git_commits_url":"https://api.github.com/repos/HusterWan/pouch/git/commits{/sha}","comments_url":"https://api.github.com/repos/HusterWan/pouch/comments{/number}","issue_comment_url":"https://api.github.com/repos/HusterWan/pouch/issues/comments{/number}","contents_url":"https://api.github.com/repos/HusterWan/pouch/contents/{+path}","compare_url":"https://api.github.com/repos/HusterWan/pouch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/HusterWan/pouch/merges","archive_url":"https://api.github.com/repos/HusterWan/pouch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/HusterWan/pouch/downloads","issues_url":"https://api.github.com/repos/HusterWan/pouch/issues{/number}","pulls_url":"https://api.github.com/repos/HusterWan/pouch/pulls{/number}","milestones_url":"https://api.github.com/repos/HusterWan/pouch/milestones{/number}","notifications_url":"https://api.github.com/repos/HusterWan/pouch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/HusterWan/pouch/labels{/name}","releases_url":"https://api.github.com/repos/HusterWan/pouch/releases{/id}","deployments_url":"https://api.github.com/repos/HusterWan/pouch/deployments","created_at":"2017-11-20T07:19:16Z","updated_at":"2018-05-03T13:01:56Z","pushed_at":"2018-05-07T07:12:33Z","git_url":"git://github.com/HusterWan/pouch.git","ssh_url":"git@github.com:HusterWan/pouch.git","clone_url":"https://github.com/HusterWan/pouch.git","svn_url":"https://github.com/HusterWan/pouch","homepage":"","size":10605,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"alibaba:master","ref":"master","sha":"ebec621c07a37adf57a3fc4ccc561e6aba198df6","user":{"login":"alibaba","id":1961952,"avatar_url":"https://avatars1.githubusercontent.com/u/1961952?v=4","gravatar_id":"","url":"https://api.github.com/users/alibaba","html_url":"https://github.com/alibaba","followers_url":"https://api.github.com/users/alibaba/followers","following_url":"https://api.github.com/users/alibaba/following{/other_user}","gists_url":"https://api.github.com/users/alibaba/gists{/gist_id}","starred_url":"https://api.github.com/users/alibaba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alibaba/subscriptions","organizations_url":"https://api.github.com/users/alibaba/orgs","repos_url":"https://api.github.com/users/alibaba/repos","events_url":"https://api.github.com/users/alibaba/events{/privacy}","received_events_url":"https://api.github.com/users/alibaba/received_events","type":"Organization","site_admin":false},"repo":{"id":102555965,"name":"pouch","full_name":"alibaba/pouch","owner":{"login":"alibaba","id":1961952,"avatar_url":"https://avatars1.githubusercontent.com/u/1961952?v=4","gravatar_id":"","url":"https://api.github.com/users/alibaba","html_url":"https://github.com/alibaba","followers_url":"https://api.github.com/users/alibaba/followers","following_url":"https://api.github.com/users/alibaba/following{/other_user}","gists_url":"https://api.github.com/users/alibaba/gists{/gist_id}","starred_url":"https://api.github.com/users/alibaba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alibaba/subscriptions","organizations_url":"https://api.github.com/users/alibaba/orgs","repos_url":"https://api.github.com/users/alibaba/repos","events_url":"https://api.github.com/users/alibaba/events{/privacy}","received_events_url":"https://api.github.com/users/alibaba/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alibaba/pouch","description":"Pouch is an open-source project created to promote the container technology movement.","fork":false,"url":"https://api.github.com/repos/alibaba/pouch","forks_url":"https://api.github.com/repos/alibaba/pouch/forks","keys_url":"https://api.github.com/repos/alibaba/pouch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alibaba/pouch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alibaba/pouch/teams","hooks_url":"https://api.github.com/repos/alibaba/pouch/hooks","issue_events_url":"https://api.github.com/repos/alibaba/pouch/issues/events{/number}","events_url":"https://api.github.com/repos/alibaba/pouch/events","assignees_url":"https://api.github.com/repos/alibaba/pouch/assignees{/user}","branches_url":"https://api.github.com/repos/alibaba/pouch/branches{/branch}","tags_url":"https://api.github.com/repos/alibaba/pouch/tags","blobs_url":"https://api.github.com/repos/alibaba/pouch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alibaba/pouch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alibaba/pouch/git/refs{/sha}","trees_url":"https://api.github.com/repos/alibaba/pouch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alibaba/pouch/statuses/{sha}","languages_url":"https://api.github.com/repos/alibaba/pouch/languages","stargazers_url":"https://api.github.com/repos/alibaba/pouch/stargazers","contributors_url":"https://api.github.com/repos/alibaba/pouch/contributors","subscribers_url":"https://api.github.com/repos/alibaba/pouch/subscribers","subscription_url":"https://api.github.com/repos/alibaba/pouch/subscription","commits_url":"https://api.github.com/repos/alibaba/pouch/commits{/sha}","git_commits_url":"https://api.github.com/repos/alibaba/pouch/git/commits{/sha}","comments_url":"https://api.github.com/repos/alibaba/pouch/comments{/number}","issue_comment_url":"https://api.github.com/repos/alibaba/pouch/issues/comments{/number}","contents_url":"https://api.github.com/repos/alibaba/pouch/contents/{+path}","compare_url":"https://api.github.com/repos/alibaba/pouch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alibaba/pouch/merges","archive_url":"https://api.github.com/repos/alibaba/pouch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alibaba/pouch/downloads","issues_url":"https://api.github.com/repos/alibaba/pouch/issues{/number}","pulls_url":"https://api.github.com/repos/alibaba/pouch/pulls{/number}","milestones_url":"https://api.github.com/repos/alibaba/pouch/milestones{/number}","notifications_url":"https://api.github.com/repos/alibaba/pouch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alibaba/pouch/labels{/name}","releases_url":"https://api.github.com/repos/alibaba/pouch/releases{/id}","deployments_url":"https://api.github.com/repos/alibaba/pouch/deployments","created_at":"2017-09-06T03:01:51Z","updated_at":"2018-05-07T06:38:47Z","pushed_at":"2018-05-07T07:12:34Z","git_url":"git://github.com/alibaba/pouch.git","ssh_url":"git@github.com:alibaba/pouch.git","clone_url":"https://github.com/alibaba/pouch.git","svn_url":"https://github.com/alibaba/pouch","homepage":"","size":10594,"stargazers_count":2577,"watchers_count":2577,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":466,"mirror_url":null,"archived":false,"open_issues_count":98,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":466,"open_issues":98,"watchers":2577,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alibaba/pouch/pulls/1275"},"html":{"href":"https://github.com/alibaba/pouch/pull/1275"},"issue":{"href":"https://api.github.com/repos/alibaba/pouch/issues/1275"},"comments":{"href":"https://api.github.com/repos/alibaba/pouch/issues/1275/comments"},"review_comments":{"href":"https://api.github.com/repos/alibaba/pouch/pulls/1275/comments"},"review_comment":{"href":"https://api.github.com/repos/alibaba/pouch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alibaba/pouch/pulls/1275/commits"},"statuses":{"href":"https://api.github.com/repos/alibaba/pouch/statuses/58c1400984a4c4493f7274d0a3c6aeefa1b93eac"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"fuweid"}}