{"action":"created","comment":{"url":"https://api.github.com/repos/moby/moby/pulls/comments/119254279","pull_request_review_id":41115968,"id":119254279,"diff_hunk":"@@ -93,33 +105,68 @@ func (l *tarexporter) parseNames(names []string) (map[image.ID]*imageDescriptor,\n \t\t\tif err != nil {\n \t\t\t\treturn nil, err\n \t\t\t}\n-\t\t\taddAssoc(imgID, nil)\n+\t\t\tif err := addAssoc(imgID, nil); err != nil {\n+\t\t\t\treturn nil, err\n+\t\t\t}\n \t\t\tcontinue\n \t\t}\n \t\tif reference.IsNameOnly(namedRef) {\n \t\t\tassocs := l.rs.ReferencesByName(namedRef)\n \t\t\tfor _, assoc := range assocs {\n-\t\t\t\taddAssoc(image.IDFromDigest(assoc.ID), assoc.Ref)\n+\t\t\t\tif err := addAssoc(image.IDFromDigest(assoc.ID), assoc.Ref); err != nil {\n+\t\t\t\t\treturn nil, err\n+\t\t\t\t}\n \t\t\t}\n \t\t\tif len(assocs) == 0 {\n \t\t\t\timgID, err := l.is.Search(name)\n \t\t\t\tif err != nil {\n \t\t\t\t\treturn nil, err\n \t\t\t\t}\n-\t\t\t\taddAssoc(imgID, nil)\n+\t\t\t\tif err := addAssoc(imgID, nil); err != nil {\n+\t\t\t\t\treturn nil, err\n+\t\t\t\t}\n \t\t\t}\n \t\t\tcontinue\n \t\t}\n \t\tid, err := l.rs.Get(namedRef)\n \t\tif err != nil {\n \t\t\treturn nil, err\n \t\t}\n-\t\taddAssoc(image.IDFromDigest(id), namedRef)\n+\t\tif err := addAssoc(image.IDFromDigest(id), namedRef); err != nil {\n+\t\t\treturn nil, err\n+\t\t}\n \n \t}\n \treturn imgDescr, nil\n }\n \n+func (l *tarexporter) takeLayerReference(id image.ID, imgDescr *imageDescriptor) error {\n+\timg, err := l.is.Get(id)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\timgDescr.image = img\n+\tif imgDescr.cachedLayer != nil {","path":"image/tarexport/save.go","position":null,"original_position":127,"commit_id":"af6d04f93d62c5dbbe349ee676c66121c9990796","original_commit_id":"b48b7efca2c65218ad410fe41d7b67f0ad086de5","user":{"login":"moypray","id":10590250,"avatar_url":"https://avatars1.githubusercontent.com/u/10590250?v=3","gravatar_id":"","url":"https://api.github.com/users/moypray","html_url":"https://github.com/moypray","followers_url":"https://api.github.com/users/moypray/followers","following_url":"https://api.github.com/users/moypray/following{/other_user}","gists_url":"https://api.github.com/users/moypray/gists{/gist_id}","starred_url":"https://api.github.com/users/moypray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moypray/subscriptions","organizations_url":"https://api.github.com/users/moypray/orgs","repos_url":"https://api.github.com/users/moypray/repos","events_url":"https://api.github.com/users/moypray/events{/privacy}","received_events_url":"https://api.github.com/users/moypray/received_events","type":"User","site_admin":false},"body":"Sorry for late, We have 3 days holiday in China.\r\n\r\nI thought if an image just have one empty layer, the `ChainID` may be emtpy string. But to check the code, it should be the empty layer ID. \r\n\r\nI think we can use `layerStore.Get` to Get an empty layer just like  [push](https://github.com/moby/moby/blob/master/distribution/push_v1.go#L217) operation.   So I think we do not need to check `nil` because of `EmptyLayer`. ( we can treat it as normal layer here)\r\n\r\nBut you mentioned that an image could have no layers and the ChainID should be empty.How does it happen? Could we use `imageStore.Get` to get this ? If couldn't, I think we should add a check here.\r\n\r\nIf I am wrong , correct me. Thanks.","created_at":"2017-05-31T01:37:16Z","updated_at":"2017-05-31T01:37:16Z","html_url":"https://github.com/moby/moby/pull/32293#discussion_r119254279","pull_request_url":"https://api.github.com/repos/moby/moby/pulls/32293","_links":{"self":{"href":"https://api.github.com/repos/moby/moby/pulls/comments/119254279"},"html":{"href":"https://github.com/moby/moby/pull/32293#discussion_r119254279"},"pull_request":{"href":"https://api.github.com/repos/moby/moby/pulls/32293"}}},"pull_request":{"url":"https://api.github.com/repos/moby/moby/pulls/32293","id":113772254,"html_url":"https://github.com/moby/moby/pull/32293","diff_url":"https://github.com/moby/moby/pull/32293.diff","patch_url":"https://github.com/moby/moby/pull/32293.patch","issue_url":"https://api.github.com/repos/moby/moby/issues/32293","number":32293,"state":"open","locked":false,"title":"Fix delete a image while saving it, delete successfully but failed to save it","user":{"login":"moypray","id":10590250,"avatar_url":"https://avatars1.githubusercontent.com/u/10590250?v=3","gravatar_id":"","url":"https://api.github.com/users/moypray","html_url":"https://github.com/moypray","followers_url":"https://api.github.com/users/moypray/followers","following_url":"https://api.github.com/users/moypray/following{/other_user}","gists_url":"https://api.github.com/users/moypray/gists{/gist_id}","starred_url":"https://api.github.com/users/moypray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moypray/subscriptions","organizations_url":"https://api.github.com/users/moypray/orgs","repos_url":"https://api.github.com/users/moypray/repos","events_url":"https://api.github.com/users/moypray/events{/privacy}","received_events_url":"https://api.github.com/users/moypray/received_events","type":"User","site_admin":false},"body":"\r\n\r\n\r\n<!--\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\n\r\nFix Issue:   https://github.com/docker/docker/issues/29653  \r\nIssue Description:\r\n * 1. Saving more than one images, `docker save -o a.tar aaa bbb`\r\n * 2. Delete the last image which in saving progress.  `docker rmi bbb`\r\n\r\nEspected:\r\n  Saving images operation shouldn't be disturbed. But the real result is that failed\r\nto save image and get an error as below:\r\n  `Error response from daemon: open\r\n/var/lib/docker/image/devicemapper/imagedb/content/sha256/7c24e4d533a76e801662ad1b7e6e06bc1204f80110b5623e96ba2877c51479a1:\r\n**- How I did it**\r\n\r\nAnalysis:\r\n 1. While saving more than one images, it will get all the image info\r\nfrom reference/imagestore, and then using the `cached data` to save the\r\nimages to a tar file.\r\n 2. But this process doesn't have a resource lock, if a deletion operation comes, the image will be deleted, so saving operation will fail.\r\n\r\nSolution:\r\n Add a `imageStateMgr` to save the image saving status, while before deleting a image, check the image status, if the image is in saving progress, stop the deletion.\r\n\r\n**- How to verify it**\r\n\r\nFirst Terminal:\r\n   docker save -o a.tar  aaa  bbb   // especially aaa is a large image.\r\nAnother Terminal:\r\n   docker rmi  bbb      // remove operation will remove bbb before save\r\n \r\n**- Description for the changelog**\r\n<!--\r\nWrite a short (one line) summary that describes the changes in this\r\npull request for inclusion in the changelog:\r\n-->\r\n\r\nSigned-off-by: Wentao Zhang <zhangwentao234@huawei.com>\r\n\r\n**- A picture of a cute animal (not mandatory but encouraged)**\r\n\r\n","created_at":"2017-04-01T09:30:06Z","updated_at":"2017-05-31T01:37:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d14b431c83a4db569766ecac9ebc32337aafdbd1","assignee":{"login":"mlaventure","id":16065150,"avatar_url":"https://avatars2.githubusercontent.com/u/16065150?v=3","gravatar_id":"","url":"https://api.github.com/users/mlaventure","html_url":"https://github.com/mlaventure","followers_url":"https://api.github.com/users/mlaventure/followers","following_url":"https://api.github.com/users/mlaventure/following{/other_user}","gists_url":"https://api.github.com/users/mlaventure/gists{/gist_id}","starred_url":"https://api.github.com/users/mlaventure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mlaventure/subscriptions","organizations_url":"https://api.github.com/users/mlaventure/orgs","repos_url":"https://api.github.com/users/mlaventure/repos","events_url":"https://api.github.com/users/mlaventure/events{/privacy}","received_events_url":"https://api.github.com/users/mlaventure/received_events","type":"User","site_admin":false},"assignees":[{"login":"mlaventure","id":16065150,"avatar_url":"https://avatars2.githubusercontent.com/u/16065150?v=3","gravatar_id":"","url":"https://api.github.com/users/mlaventure","html_url":"https://github.com/mlaventure","followers_url":"https://api.github.com/users/mlaventure/followers","following_url":"https://api.github.com/users/mlaventure/following{/other_user}","gists_url":"https://api.github.com/users/mlaventure/gists{/gist_id}","starred_url":"https://api.github.com/users/mlaventure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mlaventure/subscriptions","organizations_url":"https://api.github.com/users/mlaventure/orgs","repos_url":"https://api.github.com/users/mlaventure/repos","events_url":"https://api.github.com/users/mlaventure/events{/privacy}","received_events_url":"https://api.github.com/users/mlaventure/received_events","type":"User","site_admin":false}],"requested_reviewers":[{"login":"cpuguy83","id":799078,"avatar_url":"https://avatars0.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},{"login":"thaJeztah","id":1804568,"avatar_url":"https://avatars1.githubusercontent.com/u/1804568?v=3","gravatar_id":"","url":"https://api.github.com/users/thaJeztah","html_url":"https://github.com/thaJeztah","followers_url":"https://api.github.com/users/thaJeztah/followers","following_url":"https://api.github.com/users/thaJeztah/following{/other_user}","gists_url":"https://api.github.com/users/thaJeztah/gists{/gist_id}","starred_url":"https://api.github.com/users/thaJeztah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thaJeztah/subscriptions","organizations_url":"https://api.github.com/users/thaJeztah/orgs","repos_url":"https://api.github.com/users/thaJeztah/repos","events_url":"https://api.github.com/users/thaJeztah/events{/privacy}","received_events_url":"https://api.github.com/users/thaJeztah/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/moby/moby/pulls/32293/commits","review_comments_url":"https://api.github.com/repos/moby/moby/pulls/32293/comments","review_comment_url":"https://api.github.com/repos/moby/moby/pulls/comments{/number}","comments_url":"https://api.github.com/repos/moby/moby/issues/32293/comments","statuses_url":"https://api.github.com/repos/moby/moby/statuses/af6d04f93d62c5dbbe349ee676c66121c9990796","head":{"label":"moypray:save_delete","ref":"save_delete","sha":"af6d04f93d62c5dbbe349ee676c66121c9990796","user":{"login":"moypray","id":10590250,"avatar_url":"https://avatars1.githubusercontent.com/u/10590250?v=3","gravatar_id":"","url":"https://api.github.com/users/moypray","html_url":"https://github.com/moypray","followers_url":"https://api.github.com/users/moypray/followers","following_url":"https://api.github.com/users/moypray/following{/other_user}","gists_url":"https://api.github.com/users/moypray/gists{/gist_id}","starred_url":"https://api.github.com/users/moypray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moypray/subscriptions","organizations_url":"https://api.github.com/users/moypray/orgs","repos_url":"https://api.github.com/users/moypray/repos","events_url":"https://api.github.com/users/moypray/events{/privacy}","received_events_url":"https://api.github.com/users/moypray/received_events","type":"User","site_admin":false},"repo":{"id":85384769,"name":"docker","full_name":"moypray/docker","owner":{"login":"moypray","id":10590250,"avatar_url":"https://avatars1.githubusercontent.com/u/10590250?v=3","gravatar_id":"","url":"https://api.github.com/users/moypray","html_url":"https://github.com/moypray","followers_url":"https://api.github.com/users/moypray/followers","following_url":"https://api.github.com/users/moypray/following{/other_user}","gists_url":"https://api.github.com/users/moypray/gists{/gist_id}","starred_url":"https://api.github.com/users/moypray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moypray/subscriptions","organizations_url":"https://api.github.com/users/moypray/orgs","repos_url":"https://api.github.com/users/moypray/repos","events_url":"https://api.github.com/users/moypray/events{/privacy}","received_events_url":"https://api.github.com/users/moypray/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/moypray/docker","description":"Docker - the open-source application container engine","fork":true,"url":"https://api.github.com/repos/moypray/docker","forks_url":"https://api.github.com/repos/moypray/docker/forks","keys_url":"https://api.github.com/repos/moypray/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/moypray/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/moypray/docker/teams","hooks_url":"https://api.github.com/repos/moypray/docker/hooks","issue_events_url":"https://api.github.com/repos/moypray/docker/issues/events{/number}","events_url":"https://api.github.com/repos/moypray/docker/events","assignees_url":"https://api.github.com/repos/moypray/docker/assignees{/user}","branches_url":"https://api.github.com/repos/moypray/docker/branches{/branch}","tags_url":"https://api.github.com/repos/moypray/docker/tags","blobs_url":"https://api.github.com/repos/moypray/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/moypray/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/moypray/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/moypray/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/moypray/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/moypray/docker/languages","stargazers_url":"https://api.github.com/repos/moypray/docker/stargazers","contributors_url":"https://api.github.com/repos/moypray/docker/contributors","subscribers_url":"https://api.github.com/repos/moypray/docker/subscribers","subscription_url":"https://api.github.com/repos/moypray/docker/subscription","commits_url":"https://api.github.com/repos/moypray/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/moypray/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/moypray/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/moypray/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/moypray/docker/contents/{+path}","compare_url":"https://api.github.com/repos/moypray/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/moypray/docker/merges","archive_url":"https://api.github.com/repos/moypray/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/moypray/docker/downloads","issues_url":"https://api.github.com/repos/moypray/docker/issues{/number}","pulls_url":"https://api.github.com/repos/moypray/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/moypray/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/moypray/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/moypray/docker/labels{/name}","releases_url":"https://api.github.com/repos/moypray/docker/releases{/id}","deployments_url":"https://api.github.com/repos/moypray/docker/deployments","created_at":"2017-03-18T07:48:51Z","updated_at":"2017-03-18T07:49:10Z","pushed_at":"2017-05-25T01:52:18Z","git_url":"git://github.com/moypray/docker.git","ssh_url":"git@github.com:moypray/docker.git","clone_url":"https://github.com/moypray/docker.git","svn_url":"https://github.com/moypray/docker","homepage":"https://www.docker.com","size":129520,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"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":"moby:master","ref":"master","sha":"da3c3ec1458588d5d263dc3babd3dca95fdc7d8d","user":{"login":"moby","id":27259197,"avatar_url":"https://avatars2.githubusercontent.com/u/27259197?v=3","gravatar_id":"","url":"https://api.github.com/users/moby","html_url":"https://github.com/moby","followers_url":"https://api.github.com/users/moby/followers","following_url":"https://api.github.com/users/moby/following{/other_user}","gists_url":"https://api.github.com/users/moby/gists{/gist_id}","starred_url":"https://api.github.com/users/moby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moby/subscriptions","organizations_url":"https://api.github.com/users/moby/orgs","repos_url":"https://api.github.com/users/moby/repos","events_url":"https://api.github.com/users/moby/events{/privacy}","received_events_url":"https://api.github.com/users/moby/received_events","type":"Organization","site_admin":false},"repo":{"id":7691631,"name":"moby","full_name":"moby/moby","owner":{"login":"moby","id":27259197,"avatar_url":"https://avatars2.githubusercontent.com/u/27259197?v=3","gravatar_id":"","url":"https://api.github.com/users/moby","html_url":"https://github.com/moby","followers_url":"https://api.github.com/users/moby/followers","following_url":"https://api.github.com/users/moby/following{/other_user}","gists_url":"https://api.github.com/users/moby/gists{/gist_id}","starred_url":"https://api.github.com/users/moby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moby/subscriptions","organizations_url":"https://api.github.com/users/moby/orgs","repos_url":"https://api.github.com/users/moby/repos","events_url":"https://api.github.com/users/moby/events{/privacy}","received_events_url":"https://api.github.com/users/moby/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/moby/moby","description":"Moby Project - a collaborative project for the container ecosystem to assemble container-based systems","fork":false,"url":"https://api.github.com/repos/moby/moby","forks_url":"https://api.github.com/repos/moby/moby/forks","keys_url":"https://api.github.com/repos/moby/moby/keys{/key_id}","collaborators_url":"https://api.github.com/repos/moby/moby/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/moby/moby/teams","hooks_url":"https://api.github.com/repos/moby/moby/hooks","issue_events_url":"https://api.github.com/repos/moby/moby/issues/events{/number}","events_url":"https://api.github.com/repos/moby/moby/events","assignees_url":"https://api.github.com/repos/moby/moby/assignees{/user}","branches_url":"https://api.github.com/repos/moby/moby/branches{/branch}","tags_url":"https://api.github.com/repos/moby/moby/tags","blobs_url":"https://api.github.com/repos/moby/moby/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/moby/moby/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/moby/moby/git/refs{/sha}","trees_url":"https://api.github.com/repos/moby/moby/git/trees{/sha}","statuses_url":"https://api.github.com/repos/moby/moby/statuses/{sha}","languages_url":"https://api.github.com/repos/moby/moby/languages","stargazers_url":"https://api.github.com/repos/moby/moby/stargazers","contributors_url":"https://api.github.com/repos/moby/moby/contributors","subscribers_url":"https://api.github.com/repos/moby/moby/subscribers","subscription_url":"https://api.github.com/repos/moby/moby/subscription","commits_url":"https://api.github.com/repos/moby/moby/commits{/sha}","git_commits_url":"https://api.github.com/repos/moby/moby/git/commits{/sha}","comments_url":"https://api.github.com/repos/moby/moby/comments{/number}","issue_comment_url":"https://api.github.com/repos/moby/moby/issues/comments{/number}","contents_url":"https://api.github.com/repos/moby/moby/contents/{+path}","compare_url":"https://api.github.com/repos/moby/moby/compare/{base}...{head}","merges_url":"https://api.github.com/repos/moby/moby/merges","archive_url":"https://api.github.com/repos/moby/moby/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/moby/moby/downloads","issues_url":"https://api.github.com/repos/moby/moby/issues{/number}","pulls_url":"https://api.github.com/repos/moby/moby/pulls{/number}","milestones_url":"https://api.github.com/repos/moby/moby/milestones{/number}","notifications_url":"https://api.github.com/repos/moby/moby/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/moby/moby/labels{/name}","releases_url":"https://api.github.com/repos/moby/moby/releases{/id}","deployments_url":"https://api.github.com/repos/moby/moby/deployments","created_at":"2013-01-18T18:10:57Z","updated_at":"2017-05-31T01:14:49Z","pushed_at":"2017-05-31T01:13:43Z","git_url":"git://github.com/moby/moby.git","ssh_url":"git@github.com:moby/moby.git","clone_url":"https://github.com/moby/moby.git","svn_url":"https://github.com/moby/moby","homepage":"https://mobyproject.org/","size":130166,"stargazers_count":43873,"watchers_count":43873,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13022,"mirror_url":null,"open_issues_count":2661,"forks":13022,"open_issues":2661,"watchers":43873,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/moby/moby/pulls/32293"},"html":{"href":"https://github.com/moby/moby/pull/32293"},"issue":{"href":"https://api.github.com/repos/moby/moby/issues/32293"},"comments":{"href":"https://api.github.com/repos/moby/moby/issues/32293/comments"},"review_comments":{"href":"https://api.github.com/repos/moby/moby/pulls/32293/comments"},"review_comment":{"href":"https://api.github.com/repos/moby/moby/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/moby/moby/pulls/32293/commits"},"statuses":{"href":"https://api.github.com/repos/moby/moby/statuses/af6d04f93d62c5dbbe349ee676c66121c9990796"}}}}
{"actor":{"display_login":"moypray"}}