diff --git a/src/agent/rustjail/src/container.rs b/src/agent/rustjail/src/container.rs index 8f8c148476..5a6a456ac2 100644 --- a/src/agent/rustjail/src/container.rs +++ b/src/agent/rustjail/src/container.rs @@ -1457,7 +1457,12 @@ impl LinuxContainer { linux.cgroups_path.clone() }; - let cgroup_manager = FsManager::new(cpath.as_str())?; + let cgroup_manager = FsManager::new(cpath.as_str()).map_err(|e| { + anyhow!(format!( + "fail to create cgroup manager with path {}: {:}", + cpath, e + )) + })?; info!(logger, "new cgroup_manager {:?}", &cgroup_manager); Ok(LinuxContainer { diff --git a/src/agent/src/mount.rs b/src/agent/src/mount.rs index a94cf9ce9e..32eaeb3aa5 100644 --- a/src/agent/src/mount.rs +++ b/src/agent/src/mount.rs @@ -840,7 +840,8 @@ pub fn get_mount_fs_type_from_file(mount_file: &str, mount_point: &str) -> Resul return Err(anyhow!("Invalid mount point {}", mount_point)); } - let content = fs::read_to_string(mount_file)?; + let content = fs::read_to_string(mount_file) + .map_err(|e| anyhow!("read mount file {}: {}", mount_file, e))?; let re = Regex::new(format!("device .+ mounted on {} with fstype (.+)", mount_point).as_str())?; diff --git a/src/agent/src/rpc.rs b/src/agent/src/rpc.rs index aad1c4e1f8..e2428747e2 100644 --- a/src/agent/src/rpc.rs +++ b/src/agent/src/rpc.rs @@ -2078,6 +2078,7 @@ mod tests { let result = load_kernel_module(&m); assert!(result.is_err(), "load module should failed"); + skip_if_not_root!(); // case 3: normal module. // normally this module should eixsts... m.name = "bridge".to_string();