{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/26588221","id":26588221,"diff_hunk":"@@ -144,7 +171,39 @@ func (self *realImageManager) detectImages(detected time.Time) error {\n \treturn nil\n }\n \n-func (self *realImageManager) FreeSpace(bytesToFree int64) (int64, error) {\n+func (self *realImageManager) GarbageCollect() error {\n+\t// Get disk usage on disk holding images.\n+\tfsInfo, err := self.cadvisor.DockerImagesFsInfo()\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\tusage := int64(fsInfo.Usage)\n+\tcapacity := int64(fsInfo.Capacity)\n+\tusagePercent := int(usage * 100 / capacity)\n+\n+\t// If over the max threshold, free enough to place us at the lower threshold.\n+\tif usagePercent >= self.policy.HighThresholdPercent {\n+\t\tamountToFree := usage - (int64(self.policy.LowThresholdPercent) * capacity / 100)\n+\t\tfreed, err := self.freeSpace(amountToFree)\n+\t\tif err != nil {\n+\t\t\treturn err\n+\t\t}\n+\n+\t\tif freed < amountToFree {\n+\t\t\treturn fmt.Errorf(\"failed to garbage collect required amount of images. Wanted to free %d, but freed %d\", amountToFree, freed)","path":"pkg/kubelet/image_manager.go","position":null,"original_position":135,"commit_id":"6bcbf12a3d5ea8c43252ae48561a88f1c4574e11","original_commit_id":"a6ac10c513659bad231b3e55ecfd1ad39db1653a","user":{"login":"vmarmol","id":985208,"avatar_url":"https://avatars.githubusercontent.com/u/985208?v=3","gravatar_id":"","url":"https://api.github.com/users/vmarmol","html_url":"https://github.com/vmarmol","followers_url":"https://api.github.com/users/vmarmol/followers","following_url":"https://api.github.com/users/vmarmol/following{/other_user}","gists_url":"https://api.github.com/users/vmarmol/gists{/gist_id}","starred_url":"https://api.github.com/users/vmarmol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmarmol/subscriptions","organizations_url":"https://api.github.com/users/vmarmol/orgs","repos_url":"https://api.github.com/users/vmarmol/repos","events_url":"https://api.github.com/users/vmarmol/events{/privacy}","received_events_url":"https://api.github.com/users/vmarmol/received_events","type":"User","site_admin":false},"body":"Ah, good point we should surface an event. Will add the TODO for now.","created_at":"2015-03-17T16:19:18Z","updated_at":"2015-03-17T16:19:18Z","html_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/5512#discussion_r26588221","pull_request_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5512","_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/26588221"},"html":{"href":"https://github.com/GoogleCloudPlatform/kubernetes/pull/5512#discussion_r26588221"},"pull_request":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5512"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5512","id":31265862,"html_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/5512","diff_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/5512.diff","patch_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/5512.patch","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/5512","number":5512,"state":"open","locked":false,"title":"Introduce and implement image GC policy","user":{"login":"vmarmol","id":985208,"avatar_url":"https://avatars.githubusercontent.com/u/985208?v=3","gravatar_id":"","url":"https://api.github.com/users/vmarmol","html_url":"https://github.com/vmarmol","followers_url":"https://api.github.com/users/vmarmol/followers","following_url":"https://api.github.com/users/vmarmol/following{/other_user}","gists_url":"https://api.github.com/users/vmarmol/gists{/gist_id}","starred_url":"https://api.github.com/users/vmarmol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmarmol/subscriptions","organizations_url":"https://api.github.com/users/vmarmol/orgs","repos_url":"https://api.github.com/users/vmarmol/repos","events_url":"https://api.github.com/users/vmarmol/events{/privacy}","received_events_url":"https://api.github.com/users/vmarmol/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-03-16T17:34:20Z","updated_at":"2015-03-17T16:19:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bd7b0ae2e1a09a1ce338efd74dd978e7165ef9a6","assignee":{"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},"milestone":null,"commits_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5512/commits","review_comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5512/comments","review_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/5512/comments","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/6bcbf12a3d5ea8c43252ae48561a88f1c4574e11","head":{"label":"vmarmol:igc","ref":"igc","sha":"6bcbf12a3d5ea8c43252ae48561a88f1c4574e11","user":{"login":"vmarmol","id":985208,"avatar_url":"https://avatars.githubusercontent.com/u/985208?v=3","gravatar_id":"","url":"https://api.github.com/users/vmarmol","html_url":"https://github.com/vmarmol","followers_url":"https://api.github.com/users/vmarmol/followers","following_url":"https://api.github.com/users/vmarmol/following{/other_user}","gists_url":"https://api.github.com/users/vmarmol/gists{/gist_id}","starred_url":"https://api.github.com/users/vmarmol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmarmol/subscriptions","organizations_url":"https://api.github.com/users/vmarmol/orgs","repos_url":"https://api.github.com/users/vmarmol/repos","events_url":"https://api.github.com/users/vmarmol/events{/privacy}","received_events_url":"https://api.github.com/users/vmarmol/received_events","type":"User","site_admin":false},"repo":{"id":21019364,"name":"kubernetes","full_name":"vmarmol/kubernetes","owner":{"login":"vmarmol","id":985208,"avatar_url":"https://avatars.githubusercontent.com/u/985208?v=3","gravatar_id":"","url":"https://api.github.com/users/vmarmol","html_url":"https://github.com/vmarmol","followers_url":"https://api.github.com/users/vmarmol/followers","following_url":"https://api.github.com/users/vmarmol/following{/other_user}","gists_url":"https://api.github.com/users/vmarmol/gists{/gist_id}","starred_url":"https://api.github.com/users/vmarmol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmarmol/subscriptions","organizations_url":"https://api.github.com/users/vmarmol/orgs","repos_url":"https://api.github.com/users/vmarmol/repos","events_url":"https://api.github.com/users/vmarmol/events{/privacy}","received_events_url":"https://api.github.com/users/vmarmol/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vmarmol/kubernetes","description":"Container Cluster Manager","fork":true,"url":"https://api.github.com/repos/vmarmol/kubernetes","forks_url":"https://api.github.com/repos/vmarmol/kubernetes/forks","keys_url":"https://api.github.com/repos/vmarmol/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vmarmol/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vmarmol/kubernetes/teams","hooks_url":"https://api.github.com/repos/vmarmol/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/vmarmol/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/vmarmol/kubernetes/events","assignees_url":"https://api.github.com/repos/vmarmol/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/vmarmol/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/vmarmol/kubernetes/tags","blobs_url":"https://api.github.com/repos/vmarmol/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vmarmol/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vmarmol/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/vmarmol/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vmarmol/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/vmarmol/kubernetes/languages","stargazers_url":"https://api.github.com/repos/vmarmol/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/vmarmol/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/vmarmol/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/vmarmol/kubernetes/subscription","commits_url":"https://api.github.com/repos/vmarmol/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/vmarmol/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/vmarmol/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/vmarmol/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/vmarmol/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/vmarmol/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vmarmol/kubernetes/merges","archive_url":"https://api.github.com/repos/vmarmol/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vmarmol/kubernetes/downloads","issues_url":"https://api.github.com/repos/vmarmol/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/vmarmol/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/vmarmol/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/vmarmol/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vmarmol/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/vmarmol/kubernetes/releases{/id}","created_at":"2014-06-19T23:47:05Z","updated_at":"2014-10-03T15:37:19Z","pushed_at":"2015-03-17T16:19:15Z","git_url":"git://github.com/vmarmol/kubernetes.git","ssh_url":"git@github.com:vmarmol/kubernetes.git","clone_url":"https://github.com/vmarmol/kubernetes.git","svn_url":"https://github.com/vmarmol/kubernetes","homepage":null,"size":36032,"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":"879a39bcc475769a2f0c655317655973b6596c77","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-03-17T16:10:50Z","pushed_at":"2015-03-17T16:10:50Z","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":104657,"stargazers_count":6617,"watchers_count":6617,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1221,"mirror_url":null,"open_issues_count":760,"forks":1221,"open_issues":760,"watchers":6617,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5512"},"html":{"href":"https://github.com/GoogleCloudPlatform/kubernetes/pull/5512"},"issue":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/5512"},"comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/5512/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5512/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/5512/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/6bcbf12a3d5ea8c43252ae48561a88f1c4574e11"}}}}