{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/32476959","id":32476959,"diff_hunk":"@@ -1181,6 +1183,25 @@ func (dm *DockerManager) runContainerInPod(pod *api.Pod, container *api.Containe\n \tif err = dm.os.Symlink(containerLogFile, symlinkFile); err != nil {\n \t\tglog.Errorf(\"Failed to create symbolic link to the log file of pod %q container %q: %v\", podFullName, container.Name, err)\n \t}\n+\n+\t// Set OOM score of POD container to lower than those of the other\n+\t// containers in the pod. This ensures that it is killed only as a last\n+\t// resort.\n+\tcontainerInfo, err := dm.client.InspectContainer(string(id))\n+\tif err != nil {\n+\t\treturn \"\", err\n+\t}\n+\n+\t// Ensure the PID actually exists, else we'll move ourselves.\n+\tif containerInfo.State.Pid == 0 {\n+\t\treturn \"\", fmt.Errorf(\"failed to get init PID for Docker pod infra container %q\", string(id))\n+\t}\n+\tif container.Name == PodInfraContainerName {\n+\t\tutil.ApplyOomScoreAdj(containerInfo.State.Pid, podOomScoreAdj)\n+\t} else {\n+\t\tutil.ApplyOomScoreAdj(containerInfo.State.Pid, userContainerOomScoreAdj)","path":"pkg/kubelet/dockertools/manager.go","position":35,"original_position":35,"commit_id":"99f8ebdb3653177bbf3c18a769b3b69e24fabadd","original_commit_id":"99f8ebdb3653177bbf3c18a769b3b69e24fabadd","user":{"login":"yifan-gu","id":3278588,"avatar_url":"https://avatars.githubusercontent.com/u/3278588?v=3","gravatar_id":"","url":"https://api.github.com/users/yifan-gu","html_url":"https://github.com/yifan-gu","followers_url":"https://api.github.com/users/yifan-gu/followers","following_url":"https://api.github.com/users/yifan-gu/following{/other_user}","gists_url":"https://api.github.com/users/yifan-gu/gists{/gist_id}","starred_url":"https://api.github.com/users/yifan-gu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yifan-gu/subscriptions","organizations_url":"https://api.github.com/users/yifan-gu/orgs","repos_url":"https://api.github.com/users/yifan-gu/repos","events_url":"https://api.github.com/users/yifan-gu/events{/privacy}","received_events_url":"https://api.github.com/users/yifan-gu/received_events","type":"User","site_admin":false},"body":"Maybe add a comment here explaining why we need to explicit set the oom score adj here?","created_at":"2015-06-15T23:02:49Z","updated_at":"2015-06-15T23:02:49Z","html_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/9824#discussion_r32476959","pull_request_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/9824","_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/32476959"},"html":{"href":"https://github.com/GoogleCloudPlatform/kubernetes/pull/9824#discussion_r32476959"},"pull_request":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/9824"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/9824","id":37741592,"html_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/9824","diff_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/9824.diff","patch_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/9824.patch","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/9824","number":9824,"state":"open","locked":false,"title":"explicitly applying oom_score_adj(0) to processes of user containers","user":{"login":"dchen1107","id":7740897,"avatar_url":"https://avatars.githubusercontent.com/u/7740897?v=3","gravatar_id":"","url":"https://api.github.com/users/dchen1107","html_url":"https://github.com/dchen1107","followers_url":"https://api.github.com/users/dchen1107/followers","following_url":"https://api.github.com/users/dchen1107/following{/other_user}","gists_url":"https://api.github.com/users/dchen1107/gists{/gist_id}","starred_url":"https://api.github.com/users/dchen1107/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dchen1107/subscriptions","organizations_url":"https://api.github.com/users/dchen1107/orgs","repos_url":"https://api.github.com/users/dchen1107/repos","events_url":"https://api.github.com/users/dchen1107/events{/privacy}","received_events_url":"https://api.github.com/users/dchen1107/received_events","type":"User","site_admin":false},"body":"related to #9788 \r\n\r\ncc/ @yifan-gu \r\n\r\nWith this PR, I tested it manually against a node, and all children processes of docker daemon are have either 0 or -100 as oom_score_adj.\r\n\r\n```\r\n# for i in $(docker ps -q); do out=$(docker top $i | grep -v UID); pid=$(echo $out | awk  -F\" \" '{print $2}'); cat /proc/$pid/oom_score_adj; done\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n-100\r\n-100\r\n-100\r\n-100\r\n-100\r\n-100\r\n```\r\n\r\nI am working on a e2e test to prevent such issue from the future in a separate pr. ","created_at":"2015-06-15T22:17:00Z","updated_at":"2015-06-15T23:02:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ecc94628eff8e2a1e8bf1df943e2ae544388e057","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/9824/commits","review_comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/9824/comments","review_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/9824/comments","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/99f8ebdb3653177bbf3c18a769b3b69e24fabadd","head":{"label":"dchen1107:clean","ref":"clean","sha":"99f8ebdb3653177bbf3c18a769b3b69e24fabadd","user":{"login":"dchen1107","id":7740897,"avatar_url":"https://avatars.githubusercontent.com/u/7740897?v=3","gravatar_id":"","url":"https://api.github.com/users/dchen1107","html_url":"https://github.com/dchen1107","followers_url":"https://api.github.com/users/dchen1107/followers","following_url":"https://api.github.com/users/dchen1107/following{/other_user}","gists_url":"https://api.github.com/users/dchen1107/gists{/gist_id}","starred_url":"https://api.github.com/users/dchen1107/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dchen1107/subscriptions","organizations_url":"https://api.github.com/users/dchen1107/orgs","repos_url":"https://api.github.com/users/dchen1107/repos","events_url":"https://api.github.com/users/dchen1107/events{/privacy}","received_events_url":"https://api.github.com/users/dchen1107/received_events","type":"User","site_admin":false},"repo":{"id":21153738,"name":"kubernetes-1","full_name":"dchen1107/kubernetes-1","owner":{"login":"dchen1107","id":7740897,"avatar_url":"https://avatars.githubusercontent.com/u/7740897?v=3","gravatar_id":"","url":"https://api.github.com/users/dchen1107","html_url":"https://github.com/dchen1107","followers_url":"https://api.github.com/users/dchen1107/followers","following_url":"https://api.github.com/users/dchen1107/following{/other_user}","gists_url":"https://api.github.com/users/dchen1107/gists{/gist_id}","starred_url":"https://api.github.com/users/dchen1107/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dchen1107/subscriptions","organizations_url":"https://api.github.com/users/dchen1107/orgs","repos_url":"https://api.github.com/users/dchen1107/repos","events_url":"https://api.github.com/users/dchen1107/events{/privacy}","received_events_url":"https://api.github.com/users/dchen1107/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dchen1107/kubernetes-1","description":"Container Cluster Manager","fork":true,"url":"https://api.github.com/repos/dchen1107/kubernetes-1","forks_url":"https://api.github.com/repos/dchen1107/kubernetes-1/forks","keys_url":"https://api.github.com/repos/dchen1107/kubernetes-1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dchen1107/kubernetes-1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dchen1107/kubernetes-1/teams","hooks_url":"https://api.github.com/repos/dchen1107/kubernetes-1/hooks","issue_events_url":"https://api.github.com/repos/dchen1107/kubernetes-1/issues/events{/number}","events_url":"https://api.github.com/repos/dchen1107/kubernetes-1/events","assignees_url":"https://api.github.com/repos/dchen1107/kubernetes-1/assignees{/user}","branches_url":"https://api.github.com/repos/dchen1107/kubernetes-1/branches{/branch}","tags_url":"https://api.github.com/repos/dchen1107/kubernetes-1/tags","blobs_url":"https://api.github.com/repos/dchen1107/kubernetes-1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dchen1107/kubernetes-1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dchen1107/kubernetes-1/git/refs{/sha}","trees_url":"https://api.github.com/repos/dchen1107/kubernetes-1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dchen1107/kubernetes-1/statuses/{sha}","languages_url":"https://api.github.com/repos/dchen1107/kubernetes-1/languages","stargazers_url":"https://api.github.com/repos/dchen1107/kubernetes-1/stargazers","contributors_url":"https://api.github.com/repos/dchen1107/kubernetes-1/contributors","subscribers_url":"https://api.github.com/repos/dchen1107/kubernetes-1/subscribers","subscription_url":"https://api.github.com/repos/dchen1107/kubernetes-1/subscription","commits_url":"https://api.github.com/repos/dchen1107/kubernetes-1/commits{/sha}","git_commits_url":"https://api.github.com/repos/dchen1107/kubernetes-1/git/commits{/sha}","comments_url":"https://api.github.com/repos/dchen1107/kubernetes-1/comments{/number}","issue_comment_url":"https://api.github.com/repos/dchen1107/kubernetes-1/issues/comments{/number}","contents_url":"https://api.github.com/repos/dchen1107/kubernetes-1/contents/{+path}","compare_url":"https://api.github.com/repos/dchen1107/kubernetes-1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dchen1107/kubernetes-1/merges","archive_url":"https://api.github.com/repos/dchen1107/kubernetes-1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dchen1107/kubernetes-1/downloads","issues_url":"https://api.github.com/repos/dchen1107/kubernetes-1/issues{/number}","pulls_url":"https://api.github.com/repos/dchen1107/kubernetes-1/pulls{/number}","milestones_url":"https://api.github.com/repos/dchen1107/kubernetes-1/milestones{/number}","notifications_url":"https://api.github.com/repos/dchen1107/kubernetes-1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dchen1107/kubernetes-1/labels{/name}","releases_url":"https://api.github.com/repos/dchen1107/kubernetes-1/releases{/id}","created_at":"2014-06-24T05:53:16Z","updated_at":"2015-04-03T05:38:13Z","pushed_at":"2015-06-15T21:52:21Z","git_url":"git://github.com/dchen1107/kubernetes-1.git","ssh_url":"git@github.com:dchen1107/kubernetes-1.git","clone_url":"https://github.com/dchen1107/kubernetes-1.git","svn_url":"https://github.com/dchen1107/kubernetes-1","homepage":null,"size":74661,"stargazers_count":0,"watchers_count":0,"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":0,"default_branch":"master"}},"base":{"label":"GoogleCloudPlatform:master","ref":"master","sha":"bb5d2101a1d5725e8792d8bcb2526bbec6c3106b","user":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":20580498,"name":"kubernetes","full_name":"GoogleCloudPlatform/kubernetes","owner":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleCloudPlatform/kubernetes","description":"Container Cluster Manager from Google","fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/releases{/id}","created_at":"2014-06-06T22:56:04Z","updated_at":"2015-06-15T22:49:12Z","pushed_at":"2015-06-15T22:52:28Z","git_url":"git://github.com/GoogleCloudPlatform/kubernetes.git","ssh_url":"git@github.com:GoogleCloudPlatform/kubernetes.git","clone_url":"https://github.com/GoogleCloudPlatform/kubernetes.git","svn_url":"https://github.com/GoogleCloudPlatform/kubernetes","homepage":"http://kubernetes.io","size":284275,"stargazers_count":8437,"watchers_count":8437,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1794,"mirror_url":null,"open_issues_count":1368,"forks":1794,"open_issues":1368,"watchers":8437,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/9824"},"html":{"href":"https://github.com/GoogleCloudPlatform/kubernetes/pull/9824"},"issue":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/9824"},"comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/9824/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/9824/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/9824/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/99f8ebdb3653177bbf3c18a769b3b69e24fabadd"}}}}