{"action":"created","comment":{"url":"https://api.github.com/repos/docker/docker/pulls/comments/60122739","id":60122739,"diff_hunk":"@@ -65,9 +65,21 @@ func (m mounts) parts(i int) int {\n // 2. Select the volumes mounted from another containers. Overrides previously configured mount point destination.\n // 3. Select the bind mounts set by the client. Overrides previously configured mount point destinations.\n // 4. Cleanup old volumes that are about to be reassigned.\n-func (daemon *Daemon) registerMountPoints(container *container.Container, hostConfig *containertypes.HostConfig) error {\n+func (daemon *Daemon) registerMountPoints(container *container.Container, hostConfig *containertypes.HostConfig) (retErr error) {\n \tbinds := map[string]bool{}\n \tmountPoints := map[string]*volume.MountPoint{}\n+\tdefer func() {\n+\t\t// clean up the container mountpoints once return with error\n+\t\tif retErr != nil && len(mountPoints) != 0 {","path":"daemon/volumes.go","position":10,"original_position":10,"commit_id":"875e135ec96b60f8d1c453a423ffe35e5d2239a9","original_commit_id":"875e135ec96b60f8d1c453a423ffe35e5d2239a9","user":{"login":"cpuguy83","id":799078,"avatar_url":"https://avatars.githubusercontent.com/u/799078?v=3","gravatar_id":"","url":"https://api.github.com/users/cpuguy83","html_url":"https://github.com/cpuguy83","followers_url":"https://api.github.com/users/cpuguy83/followers","following_url":"https://api.github.com/users/cpuguy83/following{/other_user}","gists_url":"https://api.github.com/users/cpuguy83/gists{/gist_id}","starred_url":"https://api.github.com/users/cpuguy83/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpuguy83/subscriptions","organizations_url":"https://api.github.com/users/cpuguy83/orgs","repos_url":"https://api.github.com/users/cpuguy83/repos","events_url":"https://api.github.com/users/cpuguy83/events{/privacy}","received_events_url":"https://api.github.com/users/cpuguy83/received_events","type":"User","site_admin":false},"body":"no need to check `len` on `mountPoints` since it's a `range`\r\n\r\nI also think this may be too deep in the stack. I'd expect the caller to unwind this on error (and use https://github.com/docker/docker/blob/master/daemon/mounts.go#L20)","created_at":"2016-04-18T19:52:36Z","updated_at":"2016-04-18T19:52:36Z","html_url":"https://github.com/docker/docker/pull/22103#discussion_r60122739","pull_request_url":"https://api.github.com/repos/docker/docker/pulls/22103","_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/comments/60122739"},"html":{"href":"https://github.com/docker/docker/pull/22103#discussion_r60122739"},"pull_request":{"href":"https://api.github.com/repos/docker/docker/pulls/22103"}}},"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/22103","id":66771126,"html_url":"https://github.com/docker/docker/pull/22103","diff_url":"https://github.com/docker/docker/pull/22103.diff","patch_url":"https://github.com/docker/docker/pull/22103.patch","issue_url":"https://api.github.com/repos/docker/docker/issues/22103","number":22103,"state":"open","locked":false,"title":"Fix docker create with duplicate volume failed to remove","user":{"login":"coolljt0725","id":8232360,"avatar_url":"https://avatars.githubusercontent.com/u/8232360?v=3","gravatar_id":"","url":"https://api.github.com/users/coolljt0725","html_url":"https://github.com/coolljt0725","followers_url":"https://api.github.com/users/coolljt0725/followers","following_url":"https://api.github.com/users/coolljt0725/following{/other_user}","gists_url":"https://api.github.com/users/coolljt0725/gists{/gist_id}","starred_url":"https://api.github.com/users/coolljt0725/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coolljt0725/subscriptions","organizations_url":"https://api.github.com/users/coolljt0725/orgs","repos_url":"https://api.github.com/users/coolljt0725/repos","events_url":"https://api.github.com/users/coolljt0725/events{/privacy}","received_events_url":"https://api.github.com/users/coolljt0725/received_events","type":"User","site_admin":false},"body":"<!--\r\nPlease make sure you've read and understood our contributing guidelines;\r\nhttps://github.com/docker/docker/blob/master/CONTRIBUTING.md\r\n\r\n** Make sure all your commits include a signature generated with `git commit -s` **\r\n\r\nFor additional information on our contributing process, read our contributing\r\nguide https://docs.docker.com/opensource/code/\r\n\r\nIf this is a bug fix, make sure your description includes \"fixes #xxxx\", or\r\n\"closes #xxxx\"\r\n\r\nPlease provide the following information:\r\n-->\r\n\r\n**- What I did*\r\nfix #22093 \r\n**- How I did it**\r\nDuring the `registerMountPoints` on container creation, it could be some volumes register\r\nsuccessfully but some failed, this will cause the container failed but with some volumes has \r\nreference to this container, and these volume can't be remove.\r\nThe fix is to remove the mountpoints once `registerMountPoints` return failed.\r\n\r\n**- How to verify it**\r\nsee #22093 \r\n\r\n**- A picture of a cute animal (not mandatory but encouraged)**","created_at":"2016-04-17T15:14:12Z","updated_at":"2016-04-18T19:52:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1176df309984c55e470737035847e0f2c9a5a465","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/docker/docker/pulls/22103/commits","review_comments_url":"https://api.github.com/repos/docker/docker/pulls/22103/comments","review_comment_url":"https://api.github.com/repos/docker/docker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/docker/issues/22103/comments","statuses_url":"https://api.github.com/repos/docker/docker/statuses/875e135ec96b60f8d1c453a423ffe35e5d2239a9","head":{"label":"coolljt0725:fix_22093","ref":"fix_22093","sha":"875e135ec96b60f8d1c453a423ffe35e5d2239a9","user":{"login":"coolljt0725","id":8232360,"avatar_url":"https://avatars.githubusercontent.com/u/8232360?v=3","gravatar_id":"","url":"https://api.github.com/users/coolljt0725","html_url":"https://github.com/coolljt0725","followers_url":"https://api.github.com/users/coolljt0725/followers","following_url":"https://api.github.com/users/coolljt0725/following{/other_user}","gists_url":"https://api.github.com/users/coolljt0725/gists{/gist_id}","starred_url":"https://api.github.com/users/coolljt0725/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coolljt0725/subscriptions","organizations_url":"https://api.github.com/users/coolljt0725/orgs","repos_url":"https://api.github.com/users/coolljt0725/repos","events_url":"https://api.github.com/users/coolljt0725/events{/privacy}","received_events_url":"https://api.github.com/users/coolljt0725/received_events","type":"User","site_admin":false},"repo":{"id":24972258,"name":"docker","full_name":"coolljt0725/docker","owner":{"login":"coolljt0725","id":8232360,"avatar_url":"https://avatars.githubusercontent.com/u/8232360?v=3","gravatar_id":"","url":"https://api.github.com/users/coolljt0725","html_url":"https://github.com/coolljt0725","followers_url":"https://api.github.com/users/coolljt0725/followers","following_url":"https://api.github.com/users/coolljt0725/following{/other_user}","gists_url":"https://api.github.com/users/coolljt0725/gists{/gist_id}","starred_url":"https://api.github.com/users/coolljt0725/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coolljt0725/subscriptions","organizations_url":"https://api.github.com/users/coolljt0725/orgs","repos_url":"https://api.github.com/users/coolljt0725/repos","events_url":"https://api.github.com/users/coolljt0725/events{/privacy}","received_events_url":"https://api.github.com/users/coolljt0725/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/coolljt0725/docker","description":"Docker - the open-source application container engine","fork":true,"url":"https://api.github.com/repos/coolljt0725/docker","forks_url":"https://api.github.com/repos/coolljt0725/docker/forks","keys_url":"https://api.github.com/repos/coolljt0725/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coolljt0725/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coolljt0725/docker/teams","hooks_url":"https://api.github.com/repos/coolljt0725/docker/hooks","issue_events_url":"https://api.github.com/repos/coolljt0725/docker/issues/events{/number}","events_url":"https://api.github.com/repos/coolljt0725/docker/events","assignees_url":"https://api.github.com/repos/coolljt0725/docker/assignees{/user}","branches_url":"https://api.github.com/repos/coolljt0725/docker/branches{/branch}","tags_url":"https://api.github.com/repos/coolljt0725/docker/tags","blobs_url":"https://api.github.com/repos/coolljt0725/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coolljt0725/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coolljt0725/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/coolljt0725/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coolljt0725/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/coolljt0725/docker/languages","stargazers_url":"https://api.github.com/repos/coolljt0725/docker/stargazers","contributors_url":"https://api.github.com/repos/coolljt0725/docker/contributors","subscribers_url":"https://api.github.com/repos/coolljt0725/docker/subscribers","subscription_url":"https://api.github.com/repos/coolljt0725/docker/subscription","commits_url":"https://api.github.com/repos/coolljt0725/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/coolljt0725/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/coolljt0725/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/coolljt0725/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/coolljt0725/docker/contents/{+path}","compare_url":"https://api.github.com/repos/coolljt0725/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coolljt0725/docker/merges","archive_url":"https://api.github.com/repos/coolljt0725/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coolljt0725/docker/downloads","issues_url":"https://api.github.com/repos/coolljt0725/docker/issues{/number}","pulls_url":"https://api.github.com/repos/coolljt0725/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/coolljt0725/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/coolljt0725/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coolljt0725/docker/labels{/name}","releases_url":"https://api.github.com/repos/coolljt0725/docker/releases{/id}","deployments_url":"https://api.github.com/repos/coolljt0725/docker/deployments","created_at":"2014-10-09T03:32:31Z","updated_at":"2015-03-28T01:04:57Z","pushed_at":"2016-04-17T15:03:11Z","git_url":"git://github.com/coolljt0725/docker.git","ssh_url":"git@github.com:coolljt0725/docker.git","clone_url":"https://github.com/coolljt0725/docker.git","svn_url":"https://github.com/coolljt0725/docker","homepage":"http://www.docker.com","size":87124,"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":"2a95488f7843a773de2b541a47d9b971a635bfff","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}","deployments_url":"https://api.github.com/repos/docker/docker/deployments","created_at":"2013-01-18T18:10:57Z","updated_at":"2016-04-18T19:08:15Z","pushed_at":"2016-04-18T19:46:09Z","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":146038,"stargazers_count":30522,"watchers_count":30522,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8641,"mirror_url":null,"open_issues_count":1483,"forks":8641,"open_issues":1483,"watchers":30522,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/22103"},"html":{"href":"https://github.com/docker/docker/pull/22103"},"issue":{"href":"https://api.github.com/repos/docker/docker/issues/22103"},"comments":{"href":"https://api.github.com/repos/docker/docker/issues/22103/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/docker/pulls/22103/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/docker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/docker/pulls/22103/commits"},"statuses":{"href":"https://api.github.com/repos/docker/docker/statuses/875e135ec96b60f8d1c453a423ffe35e5d2239a9"}}}}