kata-containers icon indicating copy to clipboard operation
kata-containers copied to clipboard

mount: support checking multiple kinds of block device driver

Open yuchen0cc opened this issue 3 years ago • 1 comments

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]

yuchen0cc avatar Jul 26 '22 07:07 yuchen0cc

Please tell me the porting labels to be applied.

yuchen0cc avatar Jul 26 '22 07:07 yuchen0cc

Can one of the admins verify this patch?

katacontainersbot avatar Aug 26 '22 20:08 katacontainersbot

@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.

yuchen0cc avatar Jan 06 '23 07:01 yuchen0cc

What does "add-pr-size-label" failed mean ?

yuchen0cc avatar Jan 06 '23 11:01 yuchen0cc

@shuaichang Could you please have another look at reviewing this PR?

sazzy4o avatar Nov 21 '23 05:11 sazzy4o

@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?

sazzy4o avatar Nov 21 '23 16:11 sazzy4o

@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?

OK, I've rebase it by mainstream.

yuchen0cc avatar Nov 22 '23 02:11 yuchen0cc

@bergwolf Could you please review this PR?

sazzy4o avatar Nov 22 '23 03:11 sazzy4o

@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 avatar Nov 26 '23 19:11 sazzy4o

@sazzy4o sorry to forget this checking, I've fixed it.

yuchen0cc avatar Nov 27 '23 02:11 yuchen0cc

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.

yuchen0cc avatar Nov 30 '23 14:11 yuchen0cc

TestIsDeviceMapper has been moved from mount_test.go to mount_linux_test I need to move correspondingly.

yuchen0cc avatar Dec 01 '23 03:12 yuchen0cc

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

bergwolf avatar Dec 01 '23 03:12 bergwolf

I think that code looks good, but I'll try running locally (I think I should have some time to test locally tomorrow)

sazzy4o avatar Dec 01 '23 06:12 sazzy4o

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=true must be set in your configuration.toml

sazzy4o avatar Dec 03 '23 06:12 sazzy4o

/test-arm /test-s390x

jepio avatar Dec 05 '23 12:12 jepio