-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Test jailer bindmounts to root #5025
base: main
Are you sure you want to change the base?
Conversation
Hello @anthonycorletti , Thank you for your contribution! I'll take a further look at this PR later, but could you fix styling issues first? As instructed in the PR checklist, you can run the coding style test using
Thanks, |
You can squash the last two chore commits into a single commit, because the last one ("chore: fix formatting") reverts the change made in the second last ("chore: update gitignore and fix formatting"). |
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.
Some formatting changes are mixed in "test: #1099 jailer mount propagation", so could you put those formatting changes into the formatting commit?
7869e8e
to
6940c7f
Compare
thanks @zulinx86! I addressed your suggestions and cleaned up the commits/ formatting. it looks like my checkstyle is passing on my dev machine but not CI
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5025 +/- ##
=======================================
Coverage 83.13% 83.13%
=======================================
Files 245 245
Lines 26651 26651
=======================================
Hits 22156 22156
Misses 4495 4495
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
yeah, not on my dev machine as well.
it looks your commit has a long commit title ( 6940c7f ). Another nitpicking is not to use a title like "test closes #PR_ID". Keeping the commit title and message self-contained as much as possible will help future readers :) |
6940c7f
to
f99defc
Compare
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.
It looks what you implemented is different from what we want to check, because your test is just checking file existence from outside jail.
If I would reproduce in shell script what you test, it looks like:
# copying kernel and rootfs
$ echo KERNEL >kernel
$ echo ROOTFS >rootfs
# touching kernel and rootfs inside the jail to be used as mount points
$ sudo touch jail/kernel
$ sudo touch jail/rootfs
# checking the above files are created
$ ls jail/kernel
jail/kernel
$ ls jail/rootfs
jail/rootfs
# bind-mounting to the mount points
$ sudo mount --bind kernel jail/kernel
$ sudo mount --bind rootfs jail/rootfs
# checking the file existence from outside jail
$ ls jail/kernel
jail/kernel
$ ls jail/rootfs
jail/rootfs
# start microvm
# checking the file existence from outside jail
$ ls jail/kernel
jail/kernel
$ ls jail/rootfs
jail/rootfs
What we actually want to test is to check that contents of bind-mounted kernel and rootfs are propagated corrrectly inside the jail. So it's like:
# copying kernel and rootfs
$ echo KERNEL >kernel
$ echo ROOTFS >rootfs
# touching kernel and rootfs inside the jail to be used as mount points
$ sudo touch jail/kernel
$ sudo touch jail/rootfs
# bind-mounting to the mount points
$ sudo mount --bind kernel jail/kernel
$ sudo mount --bind rootfs jail/rootfs
# start microvm
# HERE, mock the jailer and this shell is inside the jail.
$ sudo unshare --mount --propagation unchanged
$ mount --make-rslave /
$ mount --rbind jail jail
$ cd jail/
# Just for simplicity, not pivot_root here.
# contents check
$ cat kernel
KERNEL
$ cat rootfs
ROOTFS
If it were the previous jailer that doesn't support bind-mounts, the result would be that the contents are not propagated properly as follows:
$ echo KERNEL >kernel
$ echo ROOTFS >rootfs
$ sudo touch jail/kernel
$ sudo touch jail/rootfs
$ sudo mount --bind kernel jail/kernel
$ sudo mount --bind rootfs jail/rootfs
# start microvm
# HERE mock preivous jailer (not supporting recursive bind-mounts)
$ sudo unshare --mount --propagation unchanged
# "MS_PRIVATE | MS_REC" instead of "MS_SLAVE | MS_REC"
$ mount --make-rprivate /
# "MS_BIND" instead of "MS_BIND | MS_REC"
$ mount --bind jail jail
$ cd jail/
# Just for simplicity, not pivot_root here.
# the contents of the kernel and rootfs are empty
$ cat kernel
$ cat rootfs
One of my dumb proposals is like:
- Make the default
test_microvm.kernel_file
andtest_microvm.rootfs_file
empty to make the microvm fail to boot if the contents of bind-mounted kernel and rootfs are not propagated correctly. - Bind-mount new kernel and rootfs onto the paths of
test_microvm.kernel_file
andtest_microvm.rootfs_file
. - Test the guest inside the microvm boots and responds to remote command execution from host.
This might not work since I don't test it on my side, so please fix as you think best.
It would be super great if you could come up with a better idea!!
This is a test for | ||
https://github.com/firecracker-microvm/firecracker/pull/#1093 |
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.
Let's make the comment self-contained and not refer to a PR.
.gitignore
Outdated
@@ -15,3 +15,4 @@ test_results/* | |||
/resources/linux | |||
/resources/x86_64 | |||
/resources/aarch64 | |||
.venv |
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.
Is this for running the python test on your own virtual env? If so, may I ask why you can't use tools/devtool test
?
e717ef4
to
89c9346
Compare
this test creates two mounts for a rootfs and guest kernel in directories that are mounted in a location that the jailer requires to boot successfully Signed-off-by: Anthony Corletti <[email protected]>
89c9346
to
39fedf1
Compare
Changes
Reason
Closes #1099
License Acceptance
By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license. For more information on following Developer
Certificate of Origin and signing off your commits, please check
CONTRIBUTING.md
.PR Checklist
tools/devtool checkstyle
to verify that the PR passes theautomated style checks.
how they are solving the problem in a clear and encompassing way.
in the PR.
CHANGELOG.md
.Runbook for Firecracker API changes.
integration tests.
TODO
.rust-vmm
.