mount: support checking multiple kinds of block device driver
Device mapper is the only supported block device driver so far, which seems limiting. Kata Containers can work well with other block devices. It is necessary to enhance supporting of multiple kinds of host block device.
Fixes #4714
Signed-off-by: yuchen.cc [email protected]
Please tell me the porting labels to be applied.
Can one of the admins verify this patch?
@bergwolf Thanks for commenting! Kata Containers has already supported using block device as container's rootfs, and it is the only way for firecracker. Device mapper is the only supported block device driver so far, which seems limiting. Actually, Kata Containers can work well with raw image on loop device or overlaybd on tcmu device. It is necessary to enhance supporting of multiple kinds of host block device driver.
I will add unit test and remove unused code.
What does "add-pr-size-label" failed mean ?
@shuaichang Could you please have another look at reviewing this PR?
@yuchen0cc Could you please merge kata-containers:main into your branch, I think one of the PR checks is failing because the branch is not up to date?
@yuchen0cc Could you please merge
kata-containers:maininto your branch, I think one of the PR checks is failing because the branch is not up to date?
OK, I've rebase it by mainstream.
@bergwolf Could you please review this PR?
@yuchen0cc It looks like one of the checks is failing because a749dd1 does not have a commit message body
I think updating it to something like this should work:
mount_test: supplement test for checking block device
Adds test for handling os.Stat error
Signed-off-by: yuchen.cc <[email protected]>
See here for more info on expected commit message format
I hope this is the last change. If you want me to take over changes to this PR, please let me know (I just need permission to push to your fork)
@sazzy4o sorry to forget this checking, I've fixed it.
As suggested by @bergwolf , I think there is no longer need to check multiple templates (using map and loop). So I squash the previous 2 commit and make it a minor change. @shuaichang @sazzy4o @bergwolf Could you please take a look at this.
TestIsDeviceMapper has been moved from mount_test.go to mount_linux_test I need to move correspondingly.
Please test the code locally before sending it for review.
# github.com/kata-containers/kata-containers/src/runtime/virtcontainers [github.com/kata-containers/kata-containers/src/runtime/virtcontainers.test]
virtcontainers/mount_linux_test.go:315:15: undefined: isDeviceMapper
virtcontainers/mount_linux_test.go:[32](https://github.com/kata-containers/kata-containers/actions/runs/7047880519/job/19205798649?pr=4743#step:9:33)1:14: undefined: isDeviceMapper
I think that code looks good, but I'll try running locally (I think I should have some time to test locally tomorrow)
Tested locally with overlaybd and it works as expected:
$ sudo nerdctl run --cgroup-manager=cgroupfs --runtime io.containerd.run.kata.v2 --snapshotter=overlaybd --rm -it registry.hub.docker.com/overlaybd/redis:6.2.1_obd /bin/sh
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda 63G 107M 60G 1% /
tmpfs 64M 0 64M 0% /dev
none 322G 179G 127G 59% /data
shm 996M 0 996M 0% /dev/shm
tmpfs 996M 0 996M 0% /sys/fs/cgroup
kataShared 322G 179G 127G 59% /etc/hosts
#
Notes:
- Tested with cloud-hypervisor
- overlaybd installed via instructions here
-
Important:
sandbox_cgroup_only=truemust be set in yourconfiguration.toml
/test-arm /test-s390x