{"action":"created","comment":{"url":"https://api.github.com/repos/openshift/origin/pulls/comments/47798480","id":47798480,"diff_hunk":"@@ -0,0 +1,74 @@\n+package reaper\n+\n+import (\n+\t\"fmt\"\n+\t\"time\"\n+\n+\tkapi \"k8s.io/kubernetes/pkg/api\"\n+\tkerrors \"k8s.io/kubernetes/pkg/api/errors\"\n+\t\"k8s.io/kubernetes/pkg/kubectl\"\n+\tkutilerrors \"k8s.io/kubernetes/pkg/util/errors\"\n+\n+\t\"github.com/openshift/origin/pkg/build/util\"\n+\t\"github.com/openshift/origin/pkg/client\"\n+)\n+\n+// NewBuildConfigReaper returns a new reaper for buildConfigs\n+func NewBuildConfigReaper(oc *client.Client) kubectl.Reaper {\n+\treturn &BuildConfigReaper{oc: oc, pollInterval: kubectl.Interval, timeout: kubectl.Timeout}\n+}\n+\n+// BuildConfigReaper implements the Reaper interface for buildConfigs\n+type BuildConfigReaper struct {\n+\toc                    client.Interface\n+\tpollInterval, timeout time.Duration\n+}\n+\n+// Stop deletes the build configuration and all of the associated builds.\n+func (reaper *BuildConfigReaper) Stop(namespace, name string, timeout time.Duration, gracePeriod *kapi.DeleteOptions) (string, error) {\n+\t// If the config is already deleted, it may still have associated\n+\t// builds which didn't get cleaned up during prior calls to Stop. If\n+\t// the config can't be found, still make an attempt to clean up the\n+\t// builds.\n+\t//\n+\t// We delete the config first to ensure no further builds will be created.\n+\terr := reaper.oc.BuildConfigs(namespace).Delete(name)\n+\tnotFound := kerrors.IsNotFound(err)\n+\tif err != nil && !notFound {\n+\t\treturn \"\", err\n+\t}\n+\n+\t// Collect builds related to the config.\n+\tbuilds, err := reaper.oc.Builds(namespace).List(util.ConfigSelector(name), nil)\n+\tif err != nil {\n+\t\treturn \"\", err\n+\t}\n+\terrList := []error{}\n+\tfor _, build := range builds.Items {\n+\t\tnotFound = false\n+\t\tif err = reaper.oc.Builds(namespace).Delete(build.Name); err != nil && !kerrors.IsNotFound(err) {","path":"pkg/build/reaper/reaper.go","position":49,"original_position":49,"commit_id":"ee02b7603a13c343377fdb6d970c9ec7df28ae77","original_commit_id":"ee02b7603a13c343377fdb6d970c9ec7df28ae77","user":{"login":"kargakis","id":3900799,"avatar_url":"https://avatars.githubusercontent.com/u/3900799?v=3","gravatar_id":"","url":"https://api.github.com/users/kargakis","html_url":"https://github.com/kargakis","followers_url":"https://api.github.com/users/kargakis/followers","following_url":"https://api.github.com/users/kargakis/following{/other_user}","gists_url":"https://api.github.com/users/kargakis/gists{/gist_id}","starred_url":"https://api.github.com/users/kargakis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kargakis/subscriptions","organizations_url":"https://api.github.com/users/kargakis/orgs","repos_url":"https://api.github.com/users/kargakis/repos","events_url":"https://api.github.com/users/kargakis/events{/privacy}","received_events_url":"https://api.github.com/users/kargakis/received_events","type":"User","site_admin":false},"body":"Yes, we should log this at least under a v4 level though","created_at":"2015-12-16T16:31:42Z","updated_at":"2015-12-16T16:31:42Z","html_url":"https://github.com/openshift/origin/pull/6185#discussion_r47798480","pull_request_url":"https://api.github.com/repos/openshift/origin/pulls/6185","_links":{"self":{"href":"https://api.github.com/repos/openshift/origin/pulls/comments/47798480"},"html":{"href":"https://github.com/openshift/origin/pull/6185#discussion_r47798480"},"pull_request":{"href":"https://api.github.com/repos/openshift/origin/pulls/6185"}}},"pull_request":{"url":"https://api.github.com/repos/openshift/origin/pulls/6185","id":52561877,"html_url":"https://github.com/openshift/origin/pull/6185","diff_url":"https://github.com/openshift/origin/pull/6185.diff","patch_url":"https://github.com/openshift/origin/pull/6185.patch","issue_url":"https://api.github.com/repos/openshift/origin/issues/6185","number":6185,"state":"open","locked":false,"title":"Implement BuildConfig reaper","user":{"login":"mnagy","id":72469,"avatar_url":"https://avatars.githubusercontent.com/u/72469?v=3","gravatar_id":"","url":"https://api.github.com/users/mnagy","html_url":"https://github.com/mnagy","followers_url":"https://api.github.com/users/mnagy/followers","following_url":"https://api.github.com/users/mnagy/following{/other_user}","gists_url":"https://api.github.com/users/mnagy/gists{/gist_id}","starred_url":"https://api.github.com/users/mnagy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mnagy/subscriptions","organizations_url":"https://api.github.com/users/mnagy/orgs","repos_url":"https://api.github.com/users/mnagy/repos","events_url":"https://api.github.com/users/mnagy/events{/privacy}","received_events_url":"https://api.github.com/users/mnagy/received_events","type":"User","site_admin":false},"body":"The reaper will delete all builds associated with the BC.\r\n\r\nThis is another shot at #5080. That one was closed, but after discussion at #5208, it became necessary to return to the previous attempt. Differences from #5080 are that we now handle deprecated labels, I've added unit tests and also extended tests from #5208.","created_at":"2015-12-03T17:00:10Z","updated_at":"2015-12-16T16:31:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c724a13dbb64a80da9ebfa0235ddbe18c042a611","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openshift/origin/pulls/6185/commits","review_comments_url":"https://api.github.com/repos/openshift/origin/pulls/6185/comments","review_comment_url":"https://api.github.com/repos/openshift/origin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openshift/origin/issues/6185/comments","statuses_url":"https://api.github.com/repos/openshift/origin/statuses/ee02b7603a13c343377fdb6d970c9ec7df28ae77","head":{"label":"mnagy:build_config_reaper","ref":"build_config_reaper","sha":"ee02b7603a13c343377fdb6d970c9ec7df28ae77","user":{"login":"mnagy","id":72469,"avatar_url":"https://avatars.githubusercontent.com/u/72469?v=3","gravatar_id":"","url":"https://api.github.com/users/mnagy","html_url":"https://github.com/mnagy","followers_url":"https://api.github.com/users/mnagy/followers","following_url":"https://api.github.com/users/mnagy/following{/other_user}","gists_url":"https://api.github.com/users/mnagy/gists{/gist_id}","starred_url":"https://api.github.com/users/mnagy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mnagy/subscriptions","organizations_url":"https://api.github.com/users/mnagy/orgs","repos_url":"https://api.github.com/users/mnagy/repos","events_url":"https://api.github.com/users/mnagy/events{/privacy}","received_events_url":"https://api.github.com/users/mnagy/received_events","type":"User","site_admin":false},"repo":{"id":29465939,"name":"origin","full_name":"mnagy/origin","owner":{"login":"mnagy","id":72469,"avatar_url":"https://avatars.githubusercontent.com/u/72469?v=3","gravatar_id":"","url":"https://api.github.com/users/mnagy","html_url":"https://github.com/mnagy","followers_url":"https://api.github.com/users/mnagy/followers","following_url":"https://api.github.com/users/mnagy/following{/other_user}","gists_url":"https://api.github.com/users/mnagy/gists{/gist_id}","starred_url":"https://api.github.com/users/mnagy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mnagy/subscriptions","organizations_url":"https://api.github.com/users/mnagy/orgs","repos_url":"https://api.github.com/users/mnagy/repos","events_url":"https://api.github.com/users/mnagy/events{/privacy}","received_events_url":"https://api.github.com/users/mnagy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mnagy/origin","description":"OpenShift 3 - build, deploy, and manage your applications with Docker and Kubernetes","fork":true,"url":"https://api.github.com/repos/mnagy/origin","forks_url":"https://api.github.com/repos/mnagy/origin/forks","keys_url":"https://api.github.com/repos/mnagy/origin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mnagy/origin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mnagy/origin/teams","hooks_url":"https://api.github.com/repos/mnagy/origin/hooks","issue_events_url":"https://api.github.com/repos/mnagy/origin/issues/events{/number}","events_url":"https://api.github.com/repos/mnagy/origin/events","assignees_url":"https://api.github.com/repos/mnagy/origin/assignees{/user}","branches_url":"https://api.github.com/repos/mnagy/origin/branches{/branch}","tags_url":"https://api.github.com/repos/mnagy/origin/tags","blobs_url":"https://api.github.com/repos/mnagy/origin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mnagy/origin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mnagy/origin/git/refs{/sha}","trees_url":"https://api.github.com/repos/mnagy/origin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mnagy/origin/statuses/{sha}","languages_url":"https://api.github.com/repos/mnagy/origin/languages","stargazers_url":"https://api.github.com/repos/mnagy/origin/stargazers","contributors_url":"https://api.github.com/repos/mnagy/origin/contributors","subscribers_url":"https://api.github.com/repos/mnagy/origin/subscribers","subscription_url":"https://api.github.com/repos/mnagy/origin/subscription","commits_url":"https://api.github.com/repos/mnagy/origin/commits{/sha}","git_commits_url":"https://api.github.com/repos/mnagy/origin/git/commits{/sha}","comments_url":"https://api.github.com/repos/mnagy/origin/comments{/number}","issue_comment_url":"https://api.github.com/repos/mnagy/origin/issues/comments{/number}","contents_url":"https://api.github.com/repos/mnagy/origin/contents/{+path}","compare_url":"https://api.github.com/repos/mnagy/origin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mnagy/origin/merges","archive_url":"https://api.github.com/repos/mnagy/origin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mnagy/origin/downloads","issues_url":"https://api.github.com/repos/mnagy/origin/issues{/number}","pulls_url":"https://api.github.com/repos/mnagy/origin/pulls{/number}","milestones_url":"https://api.github.com/repos/mnagy/origin/milestones{/number}","notifications_url":"https://api.github.com/repos/mnagy/origin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mnagy/origin/labels{/name}","releases_url":"https://api.github.com/repos/mnagy/origin/releases{/id}","created_at":"2015-01-19T10:37:11Z","updated_at":"2015-03-16T12:28:35Z","pushed_at":"2015-12-16T16:12:56Z","git_url":"git://github.com/mnagy/origin.git","ssh_url":"git@github.com:mnagy/origin.git","clone_url":"https://github.com/mnagy/origin.git","svn_url":"https://github.com/mnagy/origin","homepage":"https://openshift.github.io","size":180352,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"openshift:master","ref":"master","sha":"0d4de0b1801e8c58a28c8bcd9d12b5d0c46de1cb","user":{"login":"openshift","id":792337,"avatar_url":"https://avatars.githubusercontent.com/u/792337?v=3","gravatar_id":"","url":"https://api.github.com/users/openshift","html_url":"https://github.com/openshift","followers_url":"https://api.github.com/users/openshift/followers","following_url":"https://api.github.com/users/openshift/following{/other_user}","gists_url":"https://api.github.com/users/openshift/gists{/gist_id}","starred_url":"https://api.github.com/users/openshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openshift/subscriptions","organizations_url":"https://api.github.com/users/openshift/orgs","repos_url":"https://api.github.com/users/openshift/repos","events_url":"https://api.github.com/users/openshift/events{/privacy}","received_events_url":"https://api.github.com/users/openshift/received_events","type":"Organization","site_admin":false},"repo":{"id":22442668,"name":"origin","full_name":"openshift/origin","owner":{"login":"openshift","id":792337,"avatar_url":"https://avatars.githubusercontent.com/u/792337?v=3","gravatar_id":"","url":"https://api.github.com/users/openshift","html_url":"https://github.com/openshift","followers_url":"https://api.github.com/users/openshift/followers","following_url":"https://api.github.com/users/openshift/following{/other_user}","gists_url":"https://api.github.com/users/openshift/gists{/gist_id}","starred_url":"https://api.github.com/users/openshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openshift/subscriptions","organizations_url":"https://api.github.com/users/openshift/orgs","repos_url":"https://api.github.com/users/openshift/repos","events_url":"https://api.github.com/users/openshift/events{/privacy}","received_events_url":"https://api.github.com/users/openshift/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openshift/origin","description":"OpenShift 3 - build, deploy, and manage your applications with Docker and Kubernetes","fork":false,"url":"https://api.github.com/repos/openshift/origin","forks_url":"https://api.github.com/repos/openshift/origin/forks","keys_url":"https://api.github.com/repos/openshift/origin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openshift/origin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openshift/origin/teams","hooks_url":"https://api.github.com/repos/openshift/origin/hooks","issue_events_url":"https://api.github.com/repos/openshift/origin/issues/events{/number}","events_url":"https://api.github.com/repos/openshift/origin/events","assignees_url":"https://api.github.com/repos/openshift/origin/assignees{/user}","branches_url":"https://api.github.com/repos/openshift/origin/branches{/branch}","tags_url":"https://api.github.com/repos/openshift/origin/tags","blobs_url":"https://api.github.com/repos/openshift/origin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openshift/origin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openshift/origin/git/refs{/sha}","trees_url":"https://api.github.com/repos/openshift/origin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openshift/origin/statuses/{sha}","languages_url":"https://api.github.com/repos/openshift/origin/languages","stargazers_url":"https://api.github.com/repos/openshift/origin/stargazers","contributors_url":"https://api.github.com/repos/openshift/origin/contributors","subscribers_url":"https://api.github.com/repos/openshift/origin/subscribers","subscription_url":"https://api.github.com/repos/openshift/origin/subscription","commits_url":"https://api.github.com/repos/openshift/origin/commits{/sha}","git_commits_url":"https://api.github.com/repos/openshift/origin/git/commits{/sha}","comments_url":"https://api.github.com/repos/openshift/origin/comments{/number}","issue_comment_url":"https://api.github.com/repos/openshift/origin/issues/comments{/number}","contents_url":"https://api.github.com/repos/openshift/origin/contents/{+path}","compare_url":"https://api.github.com/repos/openshift/origin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openshift/origin/merges","archive_url":"https://api.github.com/repos/openshift/origin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openshift/origin/downloads","issues_url":"https://api.github.com/repos/openshift/origin/issues{/number}","pulls_url":"https://api.github.com/repos/openshift/origin/pulls{/number}","milestones_url":"https://api.github.com/repos/openshift/origin/milestones{/number}","notifications_url":"https://api.github.com/repos/openshift/origin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openshift/origin/labels{/name}","releases_url":"https://api.github.com/repos/openshift/origin/releases{/id}","created_at":"2014-07-30T20:04:05Z","updated_at":"2015-12-16T11:15:50Z","pushed_at":"2015-12-16T16:12:57Z","git_url":"git://github.com/openshift/origin.git","ssh_url":"git@github.com:openshift/origin.git","clone_url":"https://github.com/openshift/origin.git","svn_url":"https://github.com/openshift/origin","homepage":"http://www.openshift.org","size":230979,"stargazers_count":869,"watchers_count":869,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":554,"mirror_url":null,"open_issues_count":750,"forks":554,"open_issues":750,"watchers":869,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openshift/origin/pulls/6185"},"html":{"href":"https://github.com/openshift/origin/pull/6185"},"issue":{"href":"https://api.github.com/repos/openshift/origin/issues/6185"},"comments":{"href":"https://api.github.com/repos/openshift/origin/issues/6185/comments"},"review_comments":{"href":"https://api.github.com/repos/openshift/origin/pulls/6185/comments"},"review_comment":{"href":"https://api.github.com/repos/openshift/origin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openshift/origin/pulls/6185/commits"},"statuses":{"href":"https://api.github.com/repos/openshift/origin/statuses/ee02b7603a13c343377fdb6d970c9ec7df28ae77"}}}}