{"action":"created","comment":{"url":"https://api.github.com/repos/docker/docker/pulls/comments/26883313","id":26883313,"diff_hunk":"@@ -248,3 +255,15 @@ func (job *Job) StatusCode() int {\n func (job *Job) SetCloseIO(val bool) {\n \tjob.closeIO = val\n }\n+\n+// When called, causes the Job.WaitCancelled channel to unblock.\n+func (job *Job) Cancel() {\n+\tjob.cancelOnce.Do(func() {","path":"engine/job.go","position":28,"original_position":28,"commit_id":"54cd857cb72d14606552913898ddd9ca0adb5528","original_commit_id":"54cd857cb72d14606552913898ddd9ca0adb5528","user":{"login":"duglin","id":1944671,"avatar_url":"https://avatars.githubusercontent.com/u/1944671?v=3","gravatar_id":"","url":"https://api.github.com/users/duglin","html_url":"https://github.com/duglin","followers_url":"https://api.github.com/users/duglin/followers","following_url":"https://api.github.com/users/duglin/following{/other_user}","gists_url":"https://api.github.com/users/duglin/gists{/gist_id}","starred_url":"https://api.github.com/users/duglin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duglin/subscriptions","organizations_url":"https://api.github.com/users/duglin/orgs","repos_url":"https://api.github.com/users/duglin/repos","events_url":"https://api.github.com/users/duglin/events{/privacy}","received_events_url":"https://api.github.com/users/duglin/received_events","type":"User","site_admin":false},"body":"Can we get a `log.Infoln(\"Job canceled due to connection lost\")`  type of thing here?\r\nI was looking at the logs while I tested this and noticed that at the INFO level we print stuff about the job starting, what job it is, and it ending.  But we don't say that the engine killed it unless we turn on Debug.  For those who don't run with Debug but just INFO,I think we should be consistent and add another log line.  Then all of this info is visible at the same log level and can help figure out what actually happened.  W/o this it looks like the RUN cmd that I was on died on its own, which isn't true - the daemon killed it.","created_at":"2015-03-20T23:03:26Z","updated_at":"2015-03-20T23:03:26Z","html_url":"https://github.com/docker/docker/pull/9774#discussion_r26883313","pull_request_url":"https://api.github.com/repos/docker/docker/pulls/9774","_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/comments/26883313"},"html":{"href":"https://github.com/docker/docker/pull/9774#discussion_r26883313"},"pull_request":{"href":"https://api.github.com/repos/docker/docker/pulls/9774"}}},"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/9774","id":26450379,"html_url":"https://github.com/docker/docker/pull/9774","diff_url":"https://github.com/docker/docker/pull/9774.diff","patch_url":"https://github.com/docker/docker/pull/9774.patch","issue_url":"https://api.github.com/repos/docker/docker/issues/9774","number":9774,"state":"open","locked":false,"title":"Add basic build cancellation","user":{"login":"pwaller","id":438648,"avatar_url":"https://avatars.githubusercontent.com/u/438648?v=3","gravatar_id":"","url":"https://api.github.com/users/pwaller","html_url":"https://github.com/pwaller","followers_url":"https://api.github.com/users/pwaller/followers","following_url":"https://api.github.com/users/pwaller/following{/other_user}","gists_url":"https://api.github.com/users/pwaller/gists{/gist_id}","starred_url":"https://api.github.com/users/pwaller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pwaller/subscriptions","organizations_url":"https://api.github.com/users/pwaller/orgs","repos_url":"https://api.github.com/users/pwaller/repos","events_url":"https://api.github.com/users/pwaller/events{/privacy}","received_events_url":"https://api.github.com/users/pwaller/received_events","type":"User","site_admin":false},"body":"Cancelling the build is a desirable function. For example, let's say one wanted\r\nto hook up inotify to trigger a build/run cycle when code was edited. At the\r\nmoment if there were multiple changes in quick succession, you would end up\r\nwith many in-flight builds contending with each other, and no way to cancel\r\nthem other than restarting the docker daemon.\r\n\r\nThis PR has been optimised for being the smallest useful change. It does not\r\nrepresent the full changes needed to cancel in all circumstances yet. That\r\nwill come later, first I hope to disseminate some understanding of how to\r\nachieve this.\r\n\r\nCurrently it only allows cancellation during the command running phase. If the\r\ncommand is a `RUN` statement, the container is killed. Other statements are\r\nnot currently interrupted but instead the build is cancelled just before\r\nthe next statement.\r\n\r\nCancellation can be used by non-docker clients by cancelling the http request.\r\nThere is an example of how to do that here:\r\n\r\nhttps://github.com/fsouza/go-dockerclient/pull/183\r\n\r\n---\r\n\r\nAdd the capability to cancel the build by disconnecting the client.\r\n\r\nThis adds a `cancelled` channel which is used to signal that a build\r\nshould halt. The build is halted by sending a Kill signal and noticing\r\nthat the cancellation channel is closed.\r\n\r\nThis first pass implementation does not allow cancellation during a\r\npull, but that will come in a subsequent PR.\r\n\r\nSee also:\r\nhttps://github.com/docker/docker/issues/3654\r\nhttps://github.com/docker/docker/issues/6928\r\n\r\nNext on my TODO list will be to implement the same thing in a similar style\r\nfor `docker pull`, if this PR is accepted. That change will automatically\r\nmake the pull phase of builds cancellable, too.\r\n\r\nDocker-DCO-1.1-Signed-off-by: Peter Waller <p@pwaller.net> (github: pwaller)","created_at":"2014-12-22T11:00:48Z","updated_at":"2015-03-20T23:03:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"82f82dda3fb1413db0e5e414bc90aa7e3c60a75d","assignee":null,"milestone":{"url":"https://api.github.com/repos/docker/docker/milestones/37","html_url":"https://github.com/docker/docker/milestones/1.6.0","labels_url":"https://api.github.com/repos/docker/docker/milestones/37/labels","id":952335,"number":37,"title":"1.6.0","description":"","creator":{"login":"crosbymichael","id":749551,"avatar_url":"https://avatars.githubusercontent.com/u/749551?v=3","gravatar_id":"","url":"https://api.github.com/users/crosbymichael","html_url":"https://github.com/crosbymichael","followers_url":"https://api.github.com/users/crosbymichael/followers","following_url":"https://api.github.com/users/crosbymichael/following{/other_user}","gists_url":"https://api.github.com/users/crosbymichael/gists{/gist_id}","starred_url":"https://api.github.com/users/crosbymichael/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crosbymichael/subscriptions","organizations_url":"https://api.github.com/users/crosbymichael/orgs","repos_url":"https://api.github.com/users/crosbymichael/repos","events_url":"https://api.github.com/users/crosbymichael/events{/privacy}","received_events_url":"https://api.github.com/users/crosbymichael/received_events","type":"User","site_admin":false},"open_issues":22,"closed_issues":62,"state":"open","created_at":"2015-01-26T23:40:13Z","updated_at":"2015-03-20T22:12:49Z","due_on":"2015-03-23T07:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/docker/docker/pulls/9774/commits","review_comments_url":"https://api.github.com/repos/docker/docker/pulls/9774/comments","review_comment_url":"https://api.github.com/repos/docker/docker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/docker/issues/9774/comments","statuses_url":"https://api.github.com/repos/docker/docker/statuses/54cd857cb72d14606552913898ddd9ca0adb5528","head":{"label":"pwaller:cancellation","ref":"cancellation","sha":"54cd857cb72d14606552913898ddd9ca0adb5528","user":{"login":"pwaller","id":438648,"avatar_url":"https://avatars.githubusercontent.com/u/438648?v=3","gravatar_id":"","url":"https://api.github.com/users/pwaller","html_url":"https://github.com/pwaller","followers_url":"https://api.github.com/users/pwaller/followers","following_url":"https://api.github.com/users/pwaller/following{/other_user}","gists_url":"https://api.github.com/users/pwaller/gists{/gist_id}","starred_url":"https://api.github.com/users/pwaller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pwaller/subscriptions","organizations_url":"https://api.github.com/users/pwaller/orgs","repos_url":"https://api.github.com/users/pwaller/repos","events_url":"https://api.github.com/users/pwaller/events{/privacy}","received_events_url":"https://api.github.com/users/pwaller/received_events","type":"User","site_admin":false},"repo":{"id":16286332,"name":"docker","full_name":"pwaller/docker","owner":{"login":"pwaller","id":438648,"avatar_url":"https://avatars.githubusercontent.com/u/438648?v=3","gravatar_id":"","url":"https://api.github.com/users/pwaller","html_url":"https://github.com/pwaller","followers_url":"https://api.github.com/users/pwaller/followers","following_url":"https://api.github.com/users/pwaller/following{/other_user}","gists_url":"https://api.github.com/users/pwaller/gists{/gist_id}","starred_url":"https://api.github.com/users/pwaller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pwaller/subscriptions","organizations_url":"https://api.github.com/users/pwaller/orgs","repos_url":"https://api.github.com/users/pwaller/repos","events_url":"https://api.github.com/users/pwaller/events{/privacy}","received_events_url":"https://api.github.com/users/pwaller/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pwaller/docker","description":"Docker - the open-source application container engine","fork":true,"url":"https://api.github.com/repos/pwaller/docker","forks_url":"https://api.github.com/repos/pwaller/docker/forks","keys_url":"https://api.github.com/repos/pwaller/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pwaller/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pwaller/docker/teams","hooks_url":"https://api.github.com/repos/pwaller/docker/hooks","issue_events_url":"https://api.github.com/repos/pwaller/docker/issues/events{/number}","events_url":"https://api.github.com/repos/pwaller/docker/events","assignees_url":"https://api.github.com/repos/pwaller/docker/assignees{/user}","branches_url":"https://api.github.com/repos/pwaller/docker/branches{/branch}","tags_url":"https://api.github.com/repos/pwaller/docker/tags","blobs_url":"https://api.github.com/repos/pwaller/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pwaller/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pwaller/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/pwaller/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pwaller/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/pwaller/docker/languages","stargazers_url":"https://api.github.com/repos/pwaller/docker/stargazers","contributors_url":"https://api.github.com/repos/pwaller/docker/contributors","subscribers_url":"https://api.github.com/repos/pwaller/docker/subscribers","subscription_url":"https://api.github.com/repos/pwaller/docker/subscription","commits_url":"https://api.github.com/repos/pwaller/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/pwaller/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/pwaller/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/pwaller/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/pwaller/docker/contents/{+path}","compare_url":"https://api.github.com/repos/pwaller/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pwaller/docker/merges","archive_url":"https://api.github.com/repos/pwaller/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pwaller/docker/downloads","issues_url":"https://api.github.com/repos/pwaller/docker/issues{/number}","pulls_url":"https://api.github.com/repos/pwaller/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/pwaller/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/pwaller/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pwaller/docker/labels{/name}","releases_url":"https://api.github.com/repos/pwaller/docker/releases{/id}","created_at":"2014-01-27T17:22:29Z","updated_at":"2015-03-10T18:23:39Z","pushed_at":"2015-03-20T21:11:49Z","git_url":"git://github.com/pwaller/docker.git","ssh_url":"git@github.com:pwaller/docker.git","clone_url":"https://github.com/pwaller/docker.git","svn_url":"https://github.com/pwaller/docker","homepage":"http://www.docker.io","size":45581,"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":"docker:master","ref":"master","sha":"79744811623cc794d028abfc70ac3f58db9f4b9b","user":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"repo":{"id":7691631,"name":"docker","full_name":"docker/docker","owner":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/docker/docker","description":"Docker - the open-source application container engine","fork":false,"url":"https://api.github.com/repos/docker/docker","forks_url":"https://api.github.com/repos/docker/docker/forks","keys_url":"https://api.github.com/repos/docker/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docker/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docker/docker/teams","hooks_url":"https://api.github.com/repos/docker/docker/hooks","issue_events_url":"https://api.github.com/repos/docker/docker/issues/events{/number}","events_url":"https://api.github.com/repos/docker/docker/events","assignees_url":"https://api.github.com/repos/docker/docker/assignees{/user}","branches_url":"https://api.github.com/repos/docker/docker/branches{/branch}","tags_url":"https://api.github.com/repos/docker/docker/tags","blobs_url":"https://api.github.com/repos/docker/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docker/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docker/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/docker/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docker/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/docker/docker/languages","stargazers_url":"https://api.github.com/repos/docker/docker/stargazers","contributors_url":"https://api.github.com/repos/docker/docker/contributors","subscribers_url":"https://api.github.com/repos/docker/docker/subscribers","subscription_url":"https://api.github.com/repos/docker/docker/subscription","commits_url":"https://api.github.com/repos/docker/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/docker/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/docker/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/docker/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/docker/docker/contents/{+path}","compare_url":"https://api.github.com/repos/docker/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docker/docker/merges","archive_url":"https://api.github.com/repos/docker/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docker/docker/downloads","issues_url":"https://api.github.com/repos/docker/docker/issues{/number}","pulls_url":"https://api.github.com/repos/docker/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/docker/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/docker/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docker/docker/labels{/name}","releases_url":"https://api.github.com/repos/docker/docker/releases{/id}","created_at":"2013-01-18T18:10:57Z","updated_at":"2015-03-20T22:59:47Z","pushed_at":"2015-03-20T23:02:26Z","git_url":"git://github.com/docker/docker.git","ssh_url":"git@github.com:docker/docker.git","clone_url":"https://github.com/docker/docker.git","svn_url":"https://github.com/docker/docker","homepage":"http://www.docker.com","size":156144,"stargazers_count":20007,"watchers_count":20007,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4218,"mirror_url":null,"open_issues_count":798,"forks":4218,"open_issues":798,"watchers":20007,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/9774"},"html":{"href":"https://github.com/docker/docker/pull/9774"},"issue":{"href":"https://api.github.com/repos/docker/docker/issues/9774"},"comments":{"href":"https://api.github.com/repos/docker/docker/issues/9774/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/docker/pulls/9774/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/docker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/docker/pulls/9774/commits"},"statuses":{"href":"https://api.github.com/repos/docker/docker/statuses/54cd857cb72d14606552913898ddd9ca0adb5528"}}}}