Repository navigation
Conversation
`ImageStore.load(from:)` runs one `ImportOperation` per descriptor of the layout's index into a single ingest directory. When the content store already has a blob, `fetch` copies it into that directory with `copyItem`, and a second descriptor that reaches the same blob fails with `NSFileWriteFileExistsError`. This happens when the index lists one image under two names, as `container image save` and `docker save` of two tags write it. Ignore that error, as `fetchBlob` already does for `moveItem`: the file is named by its digest, so the existing copy has the same content. Fixes apple#1017 Signed-off-by: Dezhen Lu <dezhen.lu@student.uni-tuebingen.de>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1017.
I started from #1017 and checked it against the code.
ImageStore.load(from:)runs anImportOperationfor each descriptor of the layout'sindex.json, and all of them write into the same ingest directory. When the content store already has a blob,ImportOperation.fetchcopies it into that directory withcopyItem. If an earlier descriptor in the same load already copied it, the copy fails withNSFileWriteFileExistsError(516 /EEXIST), and the whole load fails.This change ignores that error in
fetch, the same wayfetchBlobalready ignores it formoveItem. The ingest file is named by its digest, so the copy that is already there has the same content.How I found it
From the report in #1017. I reproduced it with a unit test before changing anything.
Where this can show up in practice
Loading any OCI layout whose index lists the same image more than once, when that image (or a blob it shares) is already in the store.
container image saveof two tags of one image writes this, and so doesdocker saveof several tags. The issue has the user-level steps.Validation
macOS. I added
testLoadIndexListingOneImageUnderTwoNames(alreadyStored:)toImageStoreTests. It takes the scratch layout the existing tests use, adds a second index entry for the same manifest under another name, and loads it into an empty store (alreadyStored: false) and into a store that already has the image (alreadyStored: true).main(0ac42ce):alreadyStored: truefails withNSCocoaErrorDomain Code=516 ... because an item with the same name already exists(File exists), the error from the issue.alreadyStored: falsepasses.swift test --filter 'ImageStoreTests|ImportOperationTests|OCILayout': 20 tests in 3 suites pass.swift format lintwith.swift-format-nolintreports nothing on the two changed files.Not run:
make test(the full unit suite), the integration suite, and the Linux build.Overlap
The open #1024 changes the same
copyItemblock infetch(it falls back to the source when the stored blob disappears mid-import). It still rethrows this error while the stored blob exists, so the load in #1017 still fails with it alone. Whichever lands second will need a small rebase.