From caba78004e9430e9217a5706c44a0fca9b2576d9 Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Sat, 29 Nov 2025 21:29:33 +0100 Subject: [PATCH] Fix empty Storage section by properly aliasing command types v0.1.220 broke disk collector by changing the import from std::process::Command to tokio::process::Command, but lines 193 and 767 explicitly used std::process::Command::new() which silently failed. Solution: Import both as aliases (TokioCommand/StdCommand) and use appropriate type for each operation - async commands use TokioCommand with run_command_with_timeout, sync commands use StdCommand with system timeout wrapper. Fixes: Empty Storage section after v0.1.220 deployment Bump version to v0.1.221 --- Cargo.lock | 6 +++--- agent/Cargo.toml | 2 +- agent/src/collectors/disk.rs | 11 ++++++----- dashboard/Cargo.toml | 2 +- shared/Cargo.toml | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7b26541..211ed04 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.219" +version = "0.1.220" dependencies = [ "anyhow", "chrono", @@ -301,7 +301,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.219" +version = "0.1.220" dependencies = [ "anyhow", "async-trait", @@ -324,7 +324,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.219" +version = "0.1.220" dependencies = [ "chrono", "serde", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index 19a1dd9..94cf520 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.220" +version = "0.1.221" edition = "2021" [dependencies] diff --git a/agent/src/collectors/disk.rs b/agent/src/collectors/disk.rs index cd3af2c..fe190f2 100644 --- a/agent/src/collectors/disk.rs +++ b/agent/src/collectors/disk.rs @@ -3,7 +3,8 @@ use async_trait::async_trait; use cm_dashboard_shared::{AgentData, DriveData, FilesystemData, PoolData, HysteresisThresholds, Status}; use crate::config::DiskConfig; -use tokio::process::Command; +use tokio::process::Command as TokioCommand; +use std::process::Command as StdCommand; use std::time::Instant; use std::collections::HashMap; use tracing::debug; @@ -114,7 +115,7 @@ impl DiskCollector { async fn get_mount_devices(&self) -> Result, CollectorError> { use super::run_command_with_timeout; - let mut cmd = Command::new("lsblk"); + let mut cmd = TokioCommand::new("lsblk"); cmd.args(&["-rn", "-o", "NAME,MOUNTPOINT"]); let output = run_command_with_timeout(cmd, 2).await @@ -189,7 +190,7 @@ impl DiskCollector { /// Get filesystem info for a single mount point fn get_filesystem_info(&self, mount_point: &str) -> Result<(u64, u64), CollectorError> { - let output = std::process::Command::new("timeout") + let output = StdCommand::new("timeout") .args(&["2", "df", "--block-size=1", mount_point]) .output() .map_err(|e| CollectorError::SystemRead { @@ -420,7 +421,7 @@ impl DiskCollector { // Use direct smartctl (no sudo) - service has CAP_SYS_RAWIO and CAP_SYS_ADMIN capabilities // For NVMe drives, specify device type explicitly - let mut cmd = Command::new("smartctl"); + let mut cmd = TokioCommand::new("smartctl"); if drive_name.starts_with("nvme") { cmd.args(&["-d", "nvme", "-a", &format!("/dev/{}", drive_name)]); } else { @@ -763,7 +764,7 @@ impl DiskCollector { /// Get drive information for a mount path fn get_drive_info_for_path(&self, path: &str) -> anyhow::Result { // Use lsblk to find the backing device with timeout - let output = std::process::Command::new("timeout") + let output = StdCommand::new("timeout") .args(&["2", "lsblk", "-rn", "-o", "NAME,MOUNTPOINT"]) .output() .map_err(|e| anyhow::anyhow!("Failed to run lsblk: {}", e))?; diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index 577f153..0606823 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.220" +version = "0.1.221" edition = "2021" [dependencies] diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 61cb8d7..634eca6 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.220" +version = "0.1.221" edition = "2021" [dependencies]