{"action":"created","comment":{"url":"https://api.github.com/repos/openshift/origin/pulls/comments/59919992","id":59919992,"diff_hunk":"@@ -79,21 +81,74 @@ func (bc *BuildController) CancelBuild(build *buildapi.Build) error {\n // HandleBuild deletes pods for cancelled builds and takes new builds and puts\n // them in the pending state after creating a corresponding pod\n func (bc *BuildController) HandleBuild(build *buildapi.Build) error {\n-\tglog.V(4).Infof(\"Handling build %s/%s\", build.Namespace, build.Name)\n+\tglog.V(4).Infof(\"Handling build %s/%s (%s)\", build.Namespace, build.Name, build.Status.Phase)\n+\n+\t// If we receive build that reached its final state and the build was created\n+\t// from a serial build configuration, tag the next build in the queue for\n+\t// execution. That will produce event and the build should get executed\n+\t// immediately.\n+\tvar nextBuild *buildapi.Build\n+\tschedulePolicy := buildutil.BuildSchedulePolicy(build)\n+\tif schedulePolicy == buildapi.BuildSchedulePolicySerial {\n+\t\tvar err error\n+\t\tbcName := buildutil.ConfigNameForBuild(build)\n+\t\tif len(bcName) == 0 {\n+\t\t\treturn fmt.Errorf(\"build %s/%s has no build config label set\", build.Namespace, build.Name)\n+\t\t}\n+\t\tif nextBuild, err = bc.nextBuild(build.Namespace, bcName); err != nil {\n+\t\t\treturn err\n+\t\t}\n+\t\tif nextBuild != nil {\n+\t\t\tglog.V(5).Infof(\"Build configuration %s/%s is serial, next build is %s\", build.Namespace, bcName, nextBuild.Name)\n+\t\t\tif buildutil.IsBuildComplete(build) {\n+\t\t\t\tbc.Recorder.Eventf(nextBuild, kapi.EventTypeNormal, \"scheduled\", \"Scheduling build %s/%s to run next\", nextBuild.Namespace, nextBuild.Name)\n+\t\t\t\tnow := unversioned.Now()\n+\t\t\t\tnextBuild.Status.StartTimestamp = &now\n+\t\t\t\terr := bc.BuildUpdater.Update(nextBuild.Namespace, nextBuild)\n+\t\t\t\tif errors.IsConflict(err) {\n+\t\t\t\t\t// If the build was updated, it is most likely because it was\n+\t\t\t\t\t// cancelled. In that case, wait for the retry controller to kick the\n+\t\t\t\t\t// next build, which might take longer, but it is better than guessing\n+\t\t\t\t\t// the next build.\n+\t\t\t\t\treturn nil\n+\t\t\t\t}\n+\t\t\t\treturn err\n+\t\t\t}\n+\t\t}\n+\t}\n \n \t// A cancelling event was triggered for the build, delete its pod and update build status.\n-\tif build.Status.Cancelled && build.Status.Phase != buildapi.BuildPhaseCancelled {\n-\t\tif err := bc.CancelBuild(build); err != nil {\n-\t\t\tbuild.Status.Reason = buildapi.StatusReasonCancelBuildFailed\n-\t\t\treturn fmt.Errorf(\"Failed to cancel build %s/%s: %v, will retry\", build.Namespace, build.Name, err)\n+\tif build.Status.Phase != buildapi.BuildPhaseCancelled {\n+\t\tvar reason buildapi.StatusReason\n+\t\tswitch {\n+\t\tcase build.Status.Cancelled:\n+\t\t\treason = buildapi.StatusReasonCancelBuildFailed\n+\t\t}\n+\t\tif len(reason) != 0 {","path":"pkg/build/controller/controller.go","position":68,"original_position":68,"commit_id":"68d0bdac5916b17673695e06451439bfa55941b9","original_commit_id":"68d0bdac5916b17673695e06451439bfa55941b9","user":{"login":"bparees","id":4974046,"avatar_url":"https://avatars.githubusercontent.com/u/4974046?v=3","gravatar_id":"","url":"https://api.github.com/users/bparees","html_url":"https://github.com/bparees","followers_url":"https://api.github.com/users/bparees/followers","following_url":"https://api.github.com/users/bparees/following{/other_user}","gists_url":"https://api.github.com/users/bparees/gists{/gist_id}","starred_url":"https://api.github.com/users/bparees/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bparees/subscriptions","organizations_url":"https://api.github.com/users/bparees/orgs","repos_url":"https://api.github.com/users/bparees/repos","events_url":"https://api.github.com/users/bparees/events{/privacy}","received_events_url":"https://api.github.com/users/bparees/received_events","type":"User","site_admin":false},"body":"why isn't the content of this \"if\" just part of the case statement above?\r\n","created_at":"2016-04-15T18:34:26Z","updated_at":"2016-04-15T18:34:26Z","html_url":"https://github.com/openshift/origin/pull/8453#discussion_r59919992","pull_request_url":"https://api.github.com/repos/openshift/origin/pulls/8453","_links":{"self":{"href":"https://api.github.com/repos/openshift/origin/pulls/comments/59919992"},"html":{"href":"https://github.com/openshift/origin/pull/8453#discussion_r59919992"},"pull_request":{"href":"https://api.github.com/repos/openshift/origin/pulls/8453"}}},"pull_request":{"url":"https://api.github.com/repos/openshift/origin/pulls/8453","id":65981418,"html_url":"https://github.com/openshift/origin/pull/8453","diff_url":"https://github.com/openshift/origin/pull/8453.diff","patch_url":"https://github.com/openshift/origin/pull/8453.patch","issue_url":"https://api.github.com/repos/openshift/origin/issues/8453","number":8453,"state":"open","locked":false,"title":"Initial implementation of serial builds","user":{"login":"mfojtik","id":44136,"avatar_url":"https://avatars.githubusercontent.com/u/44136?v=3","gravatar_id":"","url":"https://api.github.com/users/mfojtik","html_url":"https://github.com/mfojtik","followers_url":"https://api.github.com/users/mfojtik/followers","following_url":"https://api.github.com/users/mfojtik/following{/other_user}","gists_url":"https://api.github.com/users/mfojtik/gists{/gist_id}","starred_url":"https://api.github.com/users/mfojtik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mfojtik/subscriptions","organizations_url":"https://api.github.com/users/mfojtik/orgs","repos_url":"https://api.github.com/users/mfojtik/repos","events_url":"https://api.github.com/users/mfojtik/events{/privacy}","received_events_url":"https://api.github.com/users/mfojtik/received_events","type":"User","site_admin":false},"body":"* Add `schedulePolicy=parallel | serial` into the `BuildConfig`.\r\n  * The `parallel` represents current behavior.\r\n  * The `serial` means the builds will be execute sequentially.\r\n\r\nThe `serial` will be default when this PR gets merged. This will be documented for users.","created_at":"2016-04-11T11:56:58Z","updated_at":"2016-04-15T18:34:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9b52c77f497e7f33a9c7ce7955c0074c9460b201","assignee":null,"milestone":{"url":"https://api.github.com/repos/openshift/origin/milestones/13","html_url":"https://github.com/openshift/origin/milestones/1.2.x","labels_url":"https://api.github.com/repos/openshift/origin/milestones/13/labels","id":1594965,"number":13,"title":"1.2.x","description":"Features delivered after 1.2.","creator":{"login":"smarterclayton","id":1163175,"avatar_url":"https://avatars.githubusercontent.com/u/1163175?v=3","gravatar_id":"","url":"https://api.github.com/users/smarterclayton","html_url":"https://github.com/smarterclayton","followers_url":"https://api.github.com/users/smarterclayton/followers","following_url":"https://api.github.com/users/smarterclayton/following{/other_user}","gists_url":"https://api.github.com/users/smarterclayton/gists{/gist_id}","starred_url":"https://api.github.com/users/smarterclayton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarterclayton/subscriptions","organizations_url":"https://api.github.com/users/smarterclayton/orgs","repos_url":"https://api.github.com/users/smarterclayton/repos","events_url":"https://api.github.com/users/smarterclayton/events{/privacy}","received_events_url":"https://api.github.com/users/smarterclayton/received_events","type":"User","site_admin":false},"open_issues":56,"closed_issues":5,"state":"open","created_at":"2016-02-20T19:27:29Z","updated_at":"2016-04-14T19:59:24Z","due_on":"2016-05-06T04:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/openshift/origin/pulls/8453/commits","review_comments_url":"https://api.github.com/repos/openshift/origin/pulls/8453/comments","review_comment_url":"https://api.github.com/repos/openshift/origin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openshift/origin/issues/8453/comments","statuses_url":"https://api.github.com/repos/openshift/origin/statuses/68d0bdac5916b17673695e06451439bfa55941b9","head":{"label":"mfojtik:serial-builds","ref":"serial-builds","sha":"68d0bdac5916b17673695e06451439bfa55941b9","user":{"login":"mfojtik","id":44136,"avatar_url":"https://avatars.githubusercontent.com/u/44136?v=3","gravatar_id":"","url":"https://api.github.com/users/mfojtik","html_url":"https://github.com/mfojtik","followers_url":"https://api.github.com/users/mfojtik/followers","following_url":"https://api.github.com/users/mfojtik/following{/other_user}","gists_url":"https://api.github.com/users/mfojtik/gists{/gist_id}","starred_url":"https://api.github.com/users/mfojtik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mfojtik/subscriptions","organizations_url":"https://api.github.com/users/mfojtik/orgs","repos_url":"https://api.github.com/users/mfojtik/repos","events_url":"https://api.github.com/users/mfojtik/events{/privacy}","received_events_url":"https://api.github.com/users/mfojtik/received_events","type":"User","site_admin":false},"repo":{"id":22954249,"name":"origin","full_name":"mfojtik/origin","owner":{"login":"mfojtik","id":44136,"avatar_url":"https://avatars.githubusercontent.com/u/44136?v=3","gravatar_id":"","url":"https://api.github.com/users/mfojtik","html_url":"https://github.com/mfojtik","followers_url":"https://api.github.com/users/mfojtik/followers","following_url":"https://api.github.com/users/mfojtik/following{/other_user}","gists_url":"https://api.github.com/users/mfojtik/gists{/gist_id}","starred_url":"https://api.github.com/users/mfojtik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mfojtik/subscriptions","organizations_url":"https://api.github.com/users/mfojtik/orgs","repos_url":"https://api.github.com/users/mfojtik/repos","events_url":"https://api.github.com/users/mfojtik/events{/privacy}","received_events_url":"https://api.github.com/users/mfojtik/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mfojtik/origin","description":"OpenShift 3 - build, deploy, and manage your applications with Docker and Kubernetes","fork":true,"url":"https://api.github.com/repos/mfojtik/origin","forks_url":"https://api.github.com/repos/mfojtik/origin/forks","keys_url":"https://api.github.com/repos/mfojtik/origin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mfojtik/origin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mfojtik/origin/teams","hooks_url":"https://api.github.com/repos/mfojtik/origin/hooks","issue_events_url":"https://api.github.com/repos/mfojtik/origin/issues/events{/number}","events_url":"https://api.github.com/repos/mfojtik/origin/events","assignees_url":"https://api.github.com/repos/mfojtik/origin/assignees{/user}","branches_url":"https://api.github.com/repos/mfojtik/origin/branches{/branch}","tags_url":"https://api.github.com/repos/mfojtik/origin/tags","blobs_url":"https://api.github.com/repos/mfojtik/origin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mfojtik/origin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mfojtik/origin/git/refs{/sha}","trees_url":"https://api.github.com/repos/mfojtik/origin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mfojtik/origin/statuses/{sha}","languages_url":"https://api.github.com/repos/mfojtik/origin/languages","stargazers_url":"https://api.github.com/repos/mfojtik/origin/stargazers","contributors_url":"https://api.github.com/repos/mfojtik/origin/contributors","subscribers_url":"https://api.github.com/repos/mfojtik/origin/subscribers","subscription_url":"https://api.github.com/repos/mfojtik/origin/subscription","commits_url":"https://api.github.com/repos/mfojtik/origin/commits{/sha}","git_commits_url":"https://api.github.com/repos/mfojtik/origin/git/commits{/sha}","comments_url":"https://api.github.com/repos/mfojtik/origin/comments{/number}","issue_comment_url":"https://api.github.com/repos/mfojtik/origin/issues/comments{/number}","contents_url":"https://api.github.com/repos/mfojtik/origin/contents/{+path}","compare_url":"https://api.github.com/repos/mfojtik/origin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mfojtik/origin/merges","archive_url":"https://api.github.com/repos/mfojtik/origin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mfojtik/origin/downloads","issues_url":"https://api.github.com/repos/mfojtik/origin/issues{/number}","pulls_url":"https://api.github.com/repos/mfojtik/origin/pulls{/number}","milestones_url":"https://api.github.com/repos/mfojtik/origin/milestones{/number}","notifications_url":"https://api.github.com/repos/mfojtik/origin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mfojtik/origin/labels{/name}","releases_url":"https://api.github.com/repos/mfojtik/origin/releases{/id}","deployments_url":"https://api.github.com/repos/mfojtik/origin/deployments","created_at":"2014-08-14T13:11:47Z","updated_at":"2016-01-12T09:38:06Z","pushed_at":"2016-04-15T09:48:43Z","git_url":"git://github.com/mfojtik/origin.git","ssh_url":"git@github.com:mfojtik/origin.git","clone_url":"https://github.com/mfojtik/origin.git","svn_url":"https://github.com/mfojtik/origin","homepage":"https://openshift.github.io","size":245543,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"openshift:master","ref":"master","sha":"fcbe87a3d4c4088adc729c2db9ca66964b859ddd","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":"The Continuous Application Platform - build, deploy, and manage cloud-native and legacy applications on Kubernetes and Docker","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}","deployments_url":"https://api.github.com/repos/openshift/origin/deployments","created_at":"2014-07-30T20:04:05Z","updated_at":"2016-04-14T13:54:02Z","pushed_at":"2016-04-15T17:11:36Z","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":321685,"stargazers_count":1218,"watchers_count":1218,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":741,"mirror_url":null,"open_issues_count":1018,"forks":741,"open_issues":1018,"watchers":1218,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openshift/origin/pulls/8453"},"html":{"href":"https://github.com/openshift/origin/pull/8453"},"issue":{"href":"https://api.github.com/repos/openshift/origin/issues/8453"},"comments":{"href":"https://api.github.com/repos/openshift/origin/issues/8453/comments"},"review_comments":{"href":"https://api.github.com/repos/openshift/origin/pulls/8453/comments"},"review_comment":{"href":"https://api.github.com/repos/openshift/origin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openshift/origin/pulls/8453/commits"},"statuses":{"href":"https://api.github.com/repos/openshift/origin/statuses/68d0bdac5916b17673695e06451439bfa55941b9"}}}}