mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-11 12:52:23 +00:00
Merge pull request #4709 from liubin/fix/4708-unwrap-error
rustjail: check result to let it return early
This commit is contained in:
commit
427b29454a
@ -786,12 +786,25 @@ fn mount_from(
|
|||||||
"create dir {}: {}",
|
"create dir {}: {}",
|
||||||
dir.to_str().unwrap(),
|
dir.to_str().unwrap(),
|
||||||
e.to_string()
|
e.to_string()
|
||||||
)
|
);
|
||||||
});
|
e
|
||||||
|
})?;
|
||||||
|
|
||||||
// make sure file exists so we can bind over it
|
// make sure file exists so we can bind over it
|
||||||
if !src.is_dir() {
|
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()
|
src.to_str().unwrap().to_string()
|
||||||
} else {
|
} else {
|
||||||
@ -804,8 +817,10 @@ fn mount_from(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = stat::stat(dest.as_str())
|
let _ = stat::stat(dest.as_str()).map_err(|e| {
|
||||||
.map_err(|e| log_child!(cfd_log, "dest stat error. {}: {:?}", dest.as_str(), e));
|
log_child!(cfd_log, "dest stat error. {}: {:?}", dest.as_str(), e);
|
||||||
|
e
|
||||||
|
})?;
|
||||||
|
|
||||||
mount(
|
mount(
|
||||||
Some(src.as_str()),
|
Some(src.as_str()),
|
||||||
|
@ -110,10 +110,6 @@ enum SubCommand {
|
|||||||
fn announce(logger: &Logger, config: &AgentConfig) {
|
fn announce(logger: &Logger, config: &AgentConfig) {
|
||||||
info!(logger, "announce";
|
info!(logger, "announce";
|
||||||
"agent-commit" => version::VERSION_COMMIT,
|
"agent-commit" => version::VERSION_COMMIT,
|
||||||
|
|
||||||
// Avoid any possibility of confusion with the old agent
|
|
||||||
"agent-type" => "rust",
|
|
||||||
|
|
||||||
"agent-version" => version::AGENT_VERSION,
|
"agent-version" => version::AGENT_VERSION,
|
||||||
"api-version" => version::API_VERSION,
|
"api-version" => version::API_VERSION,
|
||||||
"config" => format!("{:?}", config),
|
"config" => format!("{:?}", config),
|
||||||
|
@ -64,7 +64,7 @@ impl Handle {
|
|||||||
pub async fn update_interface(&mut self, iface: &Interface) -> Result<()> {
|
pub async fn update_interface(&mut self, iface: &Interface) -> Result<()> {
|
||||||
// The reliable way to find link is using hardware address
|
// The reliable way to find link is using hardware address
|
||||||
// as filter. However, hardware filter might not be supported
|
// 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
|
// target link. filter using name or family is supported, but
|
||||||
// we cannot use that to find target link.
|
// we cannot use that to find target link.
|
||||||
// let's try if hardware address filter works. -_-
|
// let's try if hardware address filter works. -_-
|
||||||
@ -178,7 +178,7 @@ impl Handle {
|
|||||||
.with_context(|| format!("Failed to parse MAC address: {}", addr))?;
|
.with_context(|| format!("Failed to parse MAC address: {}", addr))?;
|
||||||
|
|
||||||
// Hardware filter might not be supported by netlink,
|
// 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
|
stream
|
||||||
.try_filter(|f| {
|
.try_filter(|f| {
|
||||||
let result = f.nlas.iter().any(|n| match n {
|
let result = f.nlas.iter().any(|n| match n {
|
||||||
|
Loading…
Reference in New Issue
Block a user