From eec9ac81efc5482f50155d2a10f31d9de6632c96 Mon Sep 17 00:00:00 2001 From: liubin Date: Wed, 20 Jul 2022 14:26:06 +0800 Subject: [PATCH 1/2] rustjail: check result to let it return early. check the result to let it return early if there are some errors Fixes: #4708 Signed-off-by: liubin --- src/agent/rustjail/src/mount.rs | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/agent/rustjail/src/mount.rs b/src/agent/rustjail/src/mount.rs index 74742c0ffe..c36f840714 100644 --- a/src/agent/rustjail/src/mount.rs +++ b/src/agent/rustjail/src/mount.rs @@ -786,12 +786,25 @@ fn mount_from( "create dir {}: {}", dir.to_str().unwrap(), e.to_string() - ) - }); + ); + e + })?; // make sure file exists so we can bind over it if !src.is_dir() { - let _ = OpenOptions::new().create(true).write(true).open(&dest); + let _ = OpenOptions::new() + .create(true) + .write(true) + .open(&dest) + .map_err(|e| { + log_child!( + cfd_log, + "open/create dest error. {}: {:?}", + dest.as_str(), + e + ); + e + })?; } src.to_str().unwrap().to_string() } else { @@ -804,8 +817,10 @@ fn mount_from( } }; - let _ = stat::stat(dest.as_str()) - .map_err(|e| log_child!(cfd_log, "dest stat error. {}: {:?}", dest.as_str(), e)); + let _ = stat::stat(dest.as_str()).map_err(|e| { + log_child!(cfd_log, "dest stat error. {}: {:?}", dest.as_str(), e); + e + })?; mount( Some(src.as_str()), From 0d7cb7eb1640b92827342e7a149e8208180c5618 Mon Sep 17 00:00:00 2001 From: liubin Date: Thu, 21 Jul 2022 14:53:01 +0800 Subject: [PATCH 2/2] agent: delete agent-type property in announce Since there is only one type of agent now, the agent-type is not needed anymore. Signed-off-by: liubin --- src/agent/src/main.rs | 4 ---- src/agent/src/netlink.rs | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/agent/src/main.rs b/src/agent/src/main.rs index 6a023e093e..2ebd7a3fbd 100644 --- a/src/agent/src/main.rs +++ b/src/agent/src/main.rs @@ -110,10 +110,6 @@ enum SubCommand { fn announce(logger: &Logger, config: &AgentConfig) { info!(logger, "announce"; "agent-commit" => version::VERSION_COMMIT, - - // Avoid any possibility of confusion with the old agent - "agent-type" => "rust", - "agent-version" => version::AGENT_VERSION, "api-version" => version::API_VERSION, "config" => format!("{:?}", config), diff --git a/src/agent/src/netlink.rs b/src/agent/src/netlink.rs index 1de4ef6920..c6fc9c2079 100644 --- a/src/agent/src/netlink.rs +++ b/src/agent/src/netlink.rs @@ -64,7 +64,7 @@ impl Handle { pub async fn update_interface(&mut self, iface: &Interface) -> Result<()> { // The reliable way to find link is using hardware address // as filter. However, hardware filter might not be supported - // by netlink, we may have to dump link list and the find the + // by netlink, we may have to dump link list and then find the // target link. filter using name or family is supported, but // we cannot use that to find target link. // let's try if hardware address filter works. -_- @@ -178,7 +178,7 @@ impl Handle { .with_context(|| format!("Failed to parse MAC address: {}", addr))?; // Hardware filter might not be supported by netlink, - // we may have to dump link list and the find the target link. + // we may have to dump link list and then find the target link. stream .try_filter(|f| { let result = f.nlas.iter().any(|n| match n {