From 29f9015caf0fa01fc0977cfea42d01a1bf4c06ac Mon Sep 17 00:00:00 2001 From: Fupan Li Date: Tue, 1 Apr 2025 11:27:20 +0800 Subject: [PATCH] runtime-rs: rm the obsoleted ephemeral volume processing Since the ephemeral volume already has a separate volume type for processing, the processing in the virtiofs share volume can be deleted. Moreover, it is not appropriate to process the ephemeral in the share fs. Signed-off-by: Fupan Li --- .../src/share_fs/virtio_fs_share_mount.rs | 51 +------------------ 1 file changed, 1 insertion(+), 50 deletions(-) diff --git a/src/runtime-rs/crates/resource/src/share_fs/virtio_fs_share_mount.rs b/src/runtime-rs/crates/resource/src/share_fs/virtio_fs_share_mount.rs index 74943d4b9e..d817c69f86 100644 --- a/src/runtime-rs/crates/resource/src/share_fs/virtio_fs_share_mount.rs +++ b/src/runtime-rs/crates/resource/src/share_fs/virtio_fs_share_mount.rs @@ -7,12 +7,8 @@ use agent::Storage; use anyhow::{anyhow, Context, Result}; use async_trait::async_trait; -use kata_sys_util::mount::{ - bind_remount, get_mount_path, get_mount_type, umount_all, umount_timeout, -}; +use kata_sys_util::mount::{bind_remount, umount_all, umount_timeout}; use kata_types::k8s::is_watchable_mount; -use kata_types::mount; -use nix::sys::stat::stat; use std::fs; use std::path::Path; @@ -116,51 +112,6 @@ impl ShareFsMount for VirtiofsShareMount { let storages = vec![watchable_storage]; - return Ok(ShareFsMountResult { - guest_path, - storages, - }); - } else if get_mount_type(&config.mount).as_str() == mount::KATA_EPHEMERAL_VOLUME_TYPE { - // refer to the golang `handleEphemeralStorage` code at - // https://github.com/kata-containers/kata-containers/blob/9516286f6dd5cfd6b138810e5d7c9e01cf6fc043/src/runtime/virtcontainers/kata_agent.go#L1354 - - let source = &get_mount_path(config.mount.source()); - let file_stat = - stat(Path::new(source)).with_context(|| format!("mount source {}", source))?; - - // if volume's gid isn't root group(default group), this means there's - // an specific fsGroup is set on this local volume, then it should pass - // to guest. - let dir_options = if file_stat.st_gid != 0 { - vec![format!("fsgid={}", file_stat.st_gid)] - } else { - vec![] - }; - - let file_name = Path::new(source) - .file_name() - .context("get file name from mount.source")?; - let source = Path::new(EPHEMERAL_PATH) - .join(file_name) - .into_os_string() - .into_string() - .map_err(|e| anyhow!("failed to get ephemeral path {:?}", e))?; - - // Create a storage struct so that kata agent is able to create - // tmpfs backed volume inside the VM - let ephemeral_storage = agent::Storage { - driver: String::from(mount::KATA_EPHEMERAL_VOLUME_TYPE), - driver_options: Vec::new(), - source: String::from("tmpfs"), - fs_type: String::from("tmpfs"), - fs_group: None, - options: dir_options, - mount_point: source.clone(), - }; - - guest_path = source; - let storages = vec![ephemeral_storage]; - return Ok(ShareFsMountResult { guest_path, storages,