-
Notifications
You must be signed in to change notification settings - Fork 217
Add single file mount support via hardlink-based isolation for single file mounts #250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Tonight I'll add integration tests and some extra coverage for error conditions (file doesn't exist, permission denied), symlinks, malicious paths, etc. Just wanted to get the PR up to elicit early feedback. |
|
Will look after the integration test(s) are added. Can you |
dcantah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple quick thoughts
…ve existing unit test coverage
|
Integration tests added for:
Unit tests added:
|
… adjust mount destination
|
@Sunsvea Can you take a look at the test failures? |
|
Thanks @dcantah Looks like there was an issue when mounting multiple single files to the same parent directory. The mount consolidation logic was running twice - once during VM configuration and once during container processing - creating different consolidated mount instances with different hashes. To fix this I added a caching mechanism ( The consolidation logic itself works as intended: groups multiple single file mounts targeting the same parent directory into a single VirtioFS share, with files isolated using hardlinks in a temporary directory. Any thoughts on this approach? |
|
Pushing some more changes shortly to cover a few extra scenarios:
|
…rations and file validation
Resolved merge conflict in Sources/Integration/VMTests.swift by keeping both the single file mount tests and the new dev console test functionality.
|
Converted to Draft PR while I investigate the failures when tests are run in parallel. |
|
The naming/mounting conflicts for the tests should be resolved now.... Tried replicating the CI conditions the best I could locally. |
|
@dcantah Any thoughts on this one? |
|
Trying to find time to review, sorry for the delay |
|
we would like to use apple container, would be great to have this merged and released if there are no concerns? |
I can continue supporting this PR if it moves forward, but I should be transparent with @dcantah that I recently joined Apple and so there may (?) be a conflict of interest. I’m happy to move forward if he decides it is the best direction to take. |
Summary
Fixes #79 by adding single file mount support, and mount consolidation for multiple single file mounts targeting the same parent directory.
Changes
consolidatedMountsCacheso bothtoVZ()andmountAttachments()use the same consolidated instances for hash consistencyExample:
/host/config.txt → /app/config.txtand/host/secret.txt → /app/secret.txtget consolidated into a single VirtioFS share mounted at /app/ containing both files as hardlinksThis enables container configurations like:
config.mounts.append(.share(source: "/host/config.txt", destination: "/app/config.txt"))config.mounts.append(.share(source: "/host/secret.txt", destination: "/app/secret.txt"))Testing
Unit tests (
MountTests.swift):Integration tests (
VMTests.swift):