Repository navigation
Keep a directory mount when a file from the same folder is also mounted - #990
Open
guanchzhou wants to merge 1 commit into
Open
guanchzhou wants to merge 1 commit into
guanchzhou wants to merge 1 commit into
Conversation
A single-file mount is served by sharing the file's parent directory. Shares are tagged by a hash of their host path, so when that parent is also a directory mount, both use the same tag. The holding-tag filter applied when building the OCI spec then removed the user's directory mount along with the holding share, and the directory disappeared from the container without an error. When a file's parent directory is already a directory mount, reuse that share for the file and do not record its tag as a holding tag. Fixes apple/container#2148.
1 of 2 tasks
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 apple/container#2148.
Problem
A single-file mount is served by sharing the file's parent directory and bind mounting the file out of it. Shares are tagged by
hashFilePath(source), so when the file's parent is also a directory mount, the holding share and the user's share have the same tag.LinuxContainerandLinuxPoddrop every mount whose tag is inholdingDirectoryTagswhen they build the OCI spec, so the user's directory mount is dropped too. The directory disappears from the container without an error.This matches the cases reported in apple/container#2148 (comment) (C below is the failing one):
/x, one of its files at/z/f/xmissing/x, a file from another folder at/x/g/x, a file from its subfolder at/x/a/fChange
FileMountContext.preparenow collects the tags of directory mounts first. A file whose parent directory is already a directory mount reuses that share: no holding share is added and its tag is not recorded inholdingDirectoryTags. The file's bind mount still comes from/run/virtiofs/<tag>, which the directory mount provides.Testing
FileMountTestscover cases A–E, with the file listed both before and after the directory in case C. They check which destinations survive the holding-tag filter and that every file mount has a share with its tag. Without the change, only case C fails.swift testpasses.make checkpasses.