diff --git a/src/libs/kata-types/src/annotations/mod.rs b/src/libs/kata-types/src/annotations/mod.rs index 16af5ab28a..3af0563c19 100644 --- a/src/libs/kata-types/src/annotations/mod.rs +++ b/src/libs/kata-types/src/annotations/mod.rs @@ -417,10 +417,10 @@ impl Annotation { match self.get_value::(KATA_ANNO_CONTAINER_RES_SWAPPINESS) { Ok(r) => { if r.unwrap_or_default() > 100 { - return Err(io::Error::new( + Err(io::Error::new( io::ErrorKind::InvalidData, format!("{} greater than 100", r.unwrap_or_default()), - )); + )) } else { Ok(r) } diff --git a/src/runtime-rs/crates/agent/src/types.rs b/src/runtime-rs/crates/agent/src/types.rs index de88229809..da6e14430b 100644 --- a/src/runtime-rs/crates/agent/src/types.rs +++ b/src/runtime-rs/crates/agent/src/types.rs @@ -20,14 +20,9 @@ impl Empty { } } -impl Default for FSGroupChangePolicy { - fn default() -> Self { - FSGroupChangePolicy::Always - } -} - -#[derive(Debug, Clone, PartialEq)] +#[derive(Default, Debug, Clone, PartialEq)] pub enum FSGroupChangePolicy { + #[default] Always = 0, OnRootMismatch = 1, } @@ -65,18 +60,13 @@ pub struct Storage { pub mount_point: String, } -#[derive(Deserialize, Clone, PartialEq, Eq, Debug, Hash)] +#[derive(Deserialize, Default, Clone, PartialEq, Eq, Debug, Hash)] pub enum IPFamily { + #[default] V4 = 0, V6 = 1, } -impl ::std::default::Default for IPFamily { - fn default() -> Self { - IPFamily::V4 - } -} - #[derive(Deserialize, Debug, PartialEq, Clone, Default)] pub struct IPAddress { pub family: IPFamily, diff --git a/src/runtime-rs/crates/hypervisor/src/ch/inner_device.rs b/src/runtime-rs/crates/hypervisor/src/ch/inner_device.rs index f4475f66e4..c04531de48 100644 --- a/src/runtime-rs/crates/hypervisor/src/ch/inner_device.rs +++ b/src/runtime-rs/crates/hypervisor/src/ch/inner_device.rs @@ -42,7 +42,7 @@ impl CloudHypervisorInner { match device { Device::ShareFsDevice(cfg) => self.handle_share_fs_device(cfg).await, Device::HybridVsock(cfg) => self.handle_hvsock_device(&cfg).await, - _ => return Err(anyhow!("unhandled device: {:?}", device)), + _ => Err(anyhow!("unhandled device: {:?}", device)), } } diff --git a/src/runtime-rs/crates/hypervisor/src/ch/inner_hypervisor.rs b/src/runtime-rs/crates/hypervisor/src/ch/inner_hypervisor.rs index 89747d9365..fa1979e838 100644 --- a/src/runtime-rs/crates/hypervisor/src/ch/inner_hypervisor.rs +++ b/src/runtime-rs/crates/hypervisor/src/ch/inner_hypervisor.rs @@ -228,11 +228,9 @@ impl CloudHypervisorInner { let join_handle = self.cloud_hypervisor_ping_until_ready(CH_POLL_TIME_MS); - let result = tokio::time::timeout(Duration::new(timeout_secs as u64, 0), join_handle) + tokio::time::timeout(Duration::new(timeout_secs as u64, 0), join_handle) .await - .context(timeout_msg)?; - - result + .context(timeout_msg)? } async fn cloud_hypervisor_ensure_not_launched(&self) -> Result<()> { diff --git a/src/runtime-rs/crates/resource/src/network/utils/address.rs b/src/runtime-rs/crates/resource/src/network/utils/address.rs index ef3b68278c..3046d3685b 100644 --- a/src/runtime-rs/crates/resource/src/network/utils/address.rs +++ b/src/runtime-rs/crates/resource/src/network/utils/address.rs @@ -80,9 +80,7 @@ pub(crate) fn parse_ip(ip: &[u8], family: u8) -> Result { octets.copy_from_slice(&ip[..16]); Ok(IpAddr::V6(Ipv6Addr::from(octets))) } - _ => { - return Err(anyhow!("unknown IP network family {}", family)); - } + _ => Err(anyhow!("unknown IP network family {}", family)), } } diff --git a/src/runtime-rs/crates/resource/src/network/utils/mod.rs b/src/runtime-rs/crates/resource/src/network/utils/mod.rs index 74635a5d9b..341038cb9f 100644 --- a/src/runtime-rs/crates/resource/src/network/utils/mod.rs +++ b/src/runtime-rs/crates/resource/src/network/utils/mod.rs @@ -25,7 +25,7 @@ pub(crate) fn parse_mac(s: &str) -> Option { pub(crate) fn get_mac_addr(b: &[u8]) -> Result { if b.len() != 6 { - return Err(anyhow!("invalid mac address {:?}", b)); + Err(anyhow!("invalid mac address {:?}", b)) } else { Ok(format!( "{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}", diff --git a/src/runtime-rs/crates/resource/src/rootfs/mod.rs b/src/runtime-rs/crates/resource/src/rootfs/mod.rs index b18085ed80..2c9160cec8 100644 --- a/src/runtime-rs/crates/resource/src/rootfs/mod.rs +++ b/src/runtime-rs/crates/resource/src/rootfs/mod.rs @@ -79,7 +79,7 @@ impl RootFsResource { .context("new share fs rootfs")?, )) } else { - return Err(anyhow!("share fs is unavailable")); + Err(anyhow!("share fs is unavailable")) } } mounts_vec if is_single_layer_rootfs(mounts_vec) => { @@ -114,12 +114,10 @@ impl RootFsResource { inner.rootfs.push(Arc::clone(&rootfs)); Ok(rootfs) } - _ => { - return Err(anyhow!( - "unsupported rootfs mounts count {}", - rootfs_mounts.len() - )) - } + _ => Err(anyhow!( + "unsupported rootfs mounts count {}", + rootfs_mounts.len() + )), } } diff --git a/src/runtime-rs/crates/runtimes/src/manager.rs b/src/runtime-rs/crates/runtimes/src/manager.rs index b32c367735..1fa7ce4a08 100644 --- a/src/runtime-rs/crates/runtimes/src/manager.rs +++ b/src/runtime-rs/crates/runtimes/src/manager.rs @@ -397,12 +397,11 @@ fn load_config(spec: &oci::Spec, option: &Option>) -> Result path } else if let Some(option) = option { // get rid of the special characters in options to get the config path - let path = if option.len() > 2 { + if option.len() > 2 { from_utf8(&option[2..])?.to_string() } else { String::from("") - }; - path + } } else { String::from("") }; diff --git a/src/runtime-rs/crates/runtimes/virt_container/src/container_manager/process.rs b/src/runtime-rs/crates/runtimes/virt_container/src/container_manager/process.rs index 438a817e20..32856f27c3 100644 --- a/src/runtime-rs/crates/runtimes/virt_container/src/container_manager/process.rs +++ b/src/runtime-rs/crates/runtimes/virt_container/src/container_manager/process.rs @@ -132,7 +132,7 @@ impl Process { info!(self.logger, "run io copy for {}", io_name); let io_name = io_name.to_string(); let logger = self.logger.new(o!("io_name" => io_name)); - let _ = tokio::spawn(async move { + tokio::spawn(async move { match tokio::io::copy(&mut reader, &mut writer).await { Err(e) => { warn!(logger, "run_io_copy: failed to copy stream: {}", e); @@ -156,7 +156,7 @@ impl Process { let exit_notifier = self.exit_watcher_tx.take(); let status = self.status.clone(); - let _ = tokio::spawn(async move { + tokio::spawn(async move { // wait on all of the container's io stream terminated info!(logger, "begin wait group io"); wg.wait().await; diff --git a/src/runtime-rs/crates/runtimes/virt_container/src/health_check.rs b/src/runtime-rs/crates/runtimes/virt_container/src/health_check.rs index 81fb3d58b5..874ccb7f10 100644 --- a/src/runtime-rs/crates/runtimes/virt_container/src/health_check.rs +++ b/src/runtime-rs/crates/runtimes/virt_container/src/health_check.rs @@ -47,7 +47,7 @@ impl HealthCheck { let stop_rx = self.stop_rx.clone(); let keep_abnormal = self.keep_abnormal; - let _ = tokio::spawn(async move { + tokio::spawn(async move { let mut version_check_threshold_count = 0; loop { diff --git a/src/runtime-rs/crates/runtimes/virt_container/src/sandbox.rs b/src/runtime-rs/crates/runtimes/virt_container/src/sandbox.rs index c5ec38e463..8202d854d6 100644 --- a/src/runtime-rs/crates/runtimes/virt_container/src/sandbox.rs +++ b/src/runtime-rs/crates/runtimes/virt_container/src/sandbox.rs @@ -285,7 +285,7 @@ impl Sandbox for VirtSandbox { let agent = self.agent.clone(); let sender = self.msg_sender.clone(); info!(sl!(), "oom watcher start"); - let _ = tokio::spawn(async move { + tokio::spawn(async move { loop { match agent .get_oom_event(agent::Empty::new()) diff --git a/src/tools/agent-ctl/src/main.rs b/src/tools/agent-ctl/src/main.rs index f08c1a884b..a56915727f 100644 --- a/src/tools/agent-ctl/src/main.rs +++ b/src/tools/agent-ctl/src/main.rs @@ -314,7 +314,7 @@ fn real_main() -> Result<()> { Ok(()) } "connect" => connect(name, args), - _ => return Err(anyhow!(format!("invalid sub-command: {:?}", subcmd))), + _ => Err(anyhow!(format!("invalid sub-command: {:?}", subcmd))), } } diff --git a/src/tools/kata-ctl/src/arch/x86_64/mod.rs b/src/tools/kata-ctl/src/arch/x86_64/mod.rs index 0263126249..a01f4a2cdd 100644 --- a/src/tools/kata-ctl/src/arch/x86_64/mod.rs +++ b/src/tools/kata-ctl/src/arch/x86_64/mod.rs @@ -225,7 +225,7 @@ mod arch_specific { expected_param_value ); - return Err(anyhow!("{} {}", error_msg, action_msg)); + Err(anyhow!("{} {}", error_msg, action_msg)) } } diff --git a/src/tools/kata-ctl/src/ops/exec_ops.rs b/src/tools/kata-ctl/src/ops/exec_ops.rs index 2a6b970aa9..9e1d4549a3 100644 --- a/src/tools/kata-ctl/src/ops/exec_ops.rs +++ b/src/tools/kata-ctl/src/ops/exec_ops.rs @@ -326,9 +326,7 @@ fn setup_client(server_url: String, dbg_console_port: u32) -> anyhow::Result { - return Err(anyhow!("invalid URI scheme: {:?}", scheme)); - } + _ => Err(anyhow!("invalid URI scheme: {:?}", scheme)), } } diff --git a/src/tools/kata-ctl/src/ops/volume_ops.rs b/src/tools/kata-ctl/src/ops/volume_ops.rs index 60c753f6f6..1027dcb72b 100644 --- a/src/tools/kata-ctl/src/ops/volume_ops.rs +++ b/src/tools/kata-ctl/src/ops/volume_ops.rs @@ -162,7 +162,7 @@ pub fn get_sandbox_id_for_volume(volume_path: &str) -> Result { return Ok(String::from(file_name)); } - return Err(anyhow!("no sandbox found for {}", volume_path)); + Err(anyhow!("no sandbox found for {}", volume_path)) } #[cfg(test)] diff --git a/src/tools/kata-ctl/src/utils.rs b/src/tools/kata-ctl/src/utils.rs index 03c005e9fc..ba5a6497d3 100644 --- a/src/tools/kata-ctl/src/utils.rs +++ b/src/tools/kata-ctl/src/utils.rs @@ -53,7 +53,7 @@ const UNKNOWN: &str = "unknown"; fn get_field_fn(line: &str, delimiter: &str, file_name: &str) -> Result { let fields: Vec<&str> = line.split(delimiter).collect(); if fields.len() < 2 { - return Err(anyhow!("Unexpected file contents for {}", file_name)); + Err(anyhow!("Unexpected file contents for {}", file_name)) } else { let val = fields[1].trim(); Ok(String::from(val)) diff --git a/src/tools/runk/Cargo.lock b/src/tools/runk/Cargo.lock index f9ebce67b3..5b66a95fa7 100644 --- a/src/tools/runk/Cargo.lock +++ b/src/tools/runk/Cargo.lock @@ -1303,9 +1303,16 @@ name = "protobuf" version = "2.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf7e6d18738ecd0902d30d1ad232c9125985a3422929b16c65517b38adc14f96" + +[[package]] +name = "protobuf" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b55bad9126f378a853655831eb7363b7b01b81d19f8cb1218861086ca4a1a61e" dependencies = [ - "serde", - "serde_derive", + "once_cell", + "protobuf-support", + "thiserror", ] [[package]] @@ -1314,17 +1321,47 @@ version = "2.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aec1632b7c8f2e620343439a7dfd1f3c47b18906c4be58982079911482b5d707" dependencies = [ - "protobuf", + "protobuf 2.27.1", ] [[package]] -name = "protobuf-codegen-pure" -version = "2.27.1" +name = "protobuf-codegen" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f8122fdb18e55190c796b088a16bdb70cd7acdcd48f7a8b796b58c62e532cc6" +checksum = "0dd418ac3c91caa4032d37cb80ff0d44e2ebe637b2fb243b6234bf89cdac4901" dependencies = [ - "protobuf", - "protobuf-codegen", + "anyhow", + "once_cell", + "protobuf 3.2.0", + "protobuf-parse", + "regex", + "tempfile", + "thiserror", +] + +[[package]] +name = "protobuf-parse" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d39b14605eaa1f6a340aec7f320b34064feb26c93aec35d6a9a2272a8ddfa49" +dependencies = [ + "anyhow", + "indexmap", + "log", + "protobuf 3.2.0", + "protobuf-support", + "tempfile", + "thiserror", + "which", +] + +[[package]] +name = "protobuf-support" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5d4d7b8601c814cfb36bcebb79f0e61e45e1e93640cf778837833bbed05c372" +dependencies = [ + "thiserror", ] [[package]] @@ -1332,7 +1369,7 @@ name = "protocols" version = "0.1.0" dependencies = [ "oci", - "protobuf", + "protobuf 3.2.0", "ttrpc", "ttrpc-codegen", ] @@ -1530,7 +1567,7 @@ dependencies = [ "nix 0.24.2", "oci", "path-absolutize", - "protobuf", + "protobuf 3.2.0", "protocols", "regex", "rlimit", @@ -1911,43 +1948,43 @@ dependencies = [ [[package]] name = "ttrpc" -version = "0.6.1" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ecfff459a859c6ba6668ff72b34c2f1d94d9d58f7088414c2674ad0f31cc7d8" +checksum = "a35f22a2964bea14afee161665bb260b83cb48e665e0260ca06ec0e775c8b06c" dependencies = [ "byteorder", "libc", "log", "nix 0.23.1", - "protobuf", - "protobuf-codegen-pure", + "protobuf 3.2.0", + "protobuf-codegen 3.2.0", "thiserror", ] [[package]] name = "ttrpc-codegen" -version = "0.2.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "809eda4e459820237104e4b61d6b41bbe6c9e1ce6adf4057955e6e6722a90408" +checksum = "94d7f7631d7a9ebed715a47cd4cb6072cbc7ae1d4ec01598971bbec0024340c2" dependencies = [ - "protobuf", - "protobuf-codegen", - "protobuf-codegen-pure", + "protobuf 2.27.1", + "protobuf-codegen 3.2.0", + "protobuf-support", "ttrpc-compiler", ] [[package]] name = "ttrpc-compiler" -version = "0.4.1" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2978ed3fa047d8fd55cbeb4d4a61d461fb3021a90c9618519c73ce7e5bb66c15" +checksum = "ec3cb5dbf1f0865a34fe3f722290fe776cacb16f50428610b779467b76ddf647" dependencies = [ "derive-new", "prost", "prost-build", "prost-types", - "protobuf", - "protobuf-codegen", + "protobuf 2.27.1", + "protobuf-codegen 2.27.1", "tempfile", ] diff --git a/src/tools/runk/libcontainer/src/cgroup.rs b/src/tools/runk/libcontainer/src/cgroup.rs index 586c6e8943..0f4673da15 100644 --- a/src/tools/runk/libcontainer/src/cgroup.rs +++ b/src/tools/runk/libcontainer/src/cgroup.rs @@ -27,7 +27,7 @@ pub fn remove_cgroup_dir(cgroup: &cgroups::Cgroup) -> Result<()> { retries -= 1; } - return Err(anyhow!("failed to remove cgroups paths")); + Err(anyhow!("failed to remove cgroups paths")) } // Make sure we get a stable freezer state, so retry if the cgroup is still undergoing freezing. diff --git a/src/tools/runk/src/main.rs b/src/tools/runk/src/main.rs index c79746678e..2e6e5220e4 100644 --- a/src/tools/runk/src/main.rs +++ b/src/tools/runk/src/main.rs @@ -66,9 +66,7 @@ async fn cmd_run(subcmd: SubCommand, root_path: &Path, logger: &Logger) -> Resul CommonCmd::Ps(ps) => commands::ps::run(ps, root_path, logger), CommonCmd::Pause(pause) => commands::pause::run(pause, root_path, logger), CommonCmd::Resume(resume) => commands::resume::run(resume, root_path, logger), - _ => { - return Err(anyhow!("command is not implemented yet")); - } + _ => Err(anyhow!("command is not implemented yet")), }, _ => unreachable!(), } diff --git a/versions.yaml b/versions.yaml index c222499d97..0e0b88d475 100644 --- a/versions.yaml +++ b/versions.yaml @@ -321,12 +321,12 @@ languages: rust: description: "Rust language" notes: "'version' is the default minimum version used by this project." - version: "1.66.0" + version: "1.68.0" meta: description: | 'newest-version' is the latest version known to work when building Kata - newest-version: "1.66.0" + newest-version: "1.68.0" golangci-lint: description: "golangci-lint"