From 2242b5ddfe6753f150f977cd1f5517b412f1a29f Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Sun, 23 Nov 2025 17:19:15 +0100 Subject: [PATCH] Make mergerfs detection more robust to prevent discovery failures Skip mergerfs pools with numeric device references (e.g., "1:2") instead of crashing. This allows regular drive detection to work even when mergerfs uses non-standard mount formats. Preserves existing functionality for standard mergerfs setups. --- Cargo.lock | 6 +++--- agent/Cargo.toml | 2 +- agent/src/collectors/disk.rs | 18 +++++++++++++++--- dashboard/Cargo.toml | 2 +- shared/Cargo.toml | 2 +- 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0d6c917..047b9b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.118" +version = "0.1.119" dependencies = [ "anyhow", "chrono", @@ -301,7 +301,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.118" +version = "0.1.119" dependencies = [ "anyhow", "async-trait", @@ -324,7 +324,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.118" +version = "0.1.119" dependencies = [ "chrono", "serde", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index dd2be83..b007cab 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.118" +version = "0.1.119" edition = "2021" [dependencies] diff --git a/agent/src/collectors/disk.rs b/agent/src/collectors/disk.rs index ca09f7d..e49ffc2 100644 --- a/agent/src/collectors/disk.rs +++ b/agent/src/collectors/disk.rs @@ -202,15 +202,27 @@ impl DiskCollector { let (total_bytes, used_bytes) = self.get_filesystem_info(&mount_point) .unwrap_or((0, 0)); - // Parse member paths + // Parse member paths - handle both full paths and numeric references let member_paths: Vec = device_sources .split(':') .map(|s| s.trim().to_string()) .filter(|s| !s.is_empty()) .collect(); + // Skip this pool if we can't parse the member paths (e.g., numeric references like "1:2") + if member_paths.iter().any(|path| !path.starts_with('/')) { + debug!("Skipping mergerfs pool {} with unparseable member paths: {:?}", mount_point, member_paths); + continue; + } + // Categorize as data vs parity drives - let (data_drives, parity_drives) = self.categorize_pool_drives(&member_paths)?; + let (data_drives, parity_drives) = match self.categorize_pool_drives(&member_paths) { + Ok(drives) => drives, + Err(e) => { + debug!("Failed to categorize drives for pool {}: {}. Skipping.", mount_point, e); + continue; + } + }; pools.push(MergerfsPool { mount_point, @@ -506,7 +518,7 @@ impl Collector for DiskCollector { let topology = match self.discover_storage() { Ok(topology) => topology, Err(e) => { - debug!("Storage discovery failed: {}", e); + tracing::error!("Storage discovery failed: {}", e); return Ok(metrics); } }; diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index 0cd0f7c..482d896 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.118" +version = "0.1.119" edition = "2021" [dependencies] diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 241d28a..ec9f4e6 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.118" +version = "0.1.119" edition = "2021" [dependencies]