Fix SnapRAID parity association using directory-based discovery
All checks were successful
Build and Release / build-and-release (push) Successful in 1m8s
All checks were successful
Build and Release / build-and-release (push) Successful in 1m8s
- Replace blanket parity drive inclusion with smart relationship detection - Only associate parity drives from same parent directory as data drives - Prevent incorrect exclusion of nvme0n1 physical drives from grouping - Maintain zero-configuration auto-discovery without hardcoded paths
This commit is contained in:
parent
ba03623110
commit
53dbb43352
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard"
|
name = "cm-dashboard"
|
||||||
version = "0.1.127"
|
version = "0.1.128"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
@ -301,7 +301,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard-agent"
|
name = "cm-dashboard-agent"
|
||||||
version = "0.1.127"
|
version = "0.1.128"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@ -324,7 +324,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard-shared"
|
name = "cm-dashboard-shared"
|
||||||
version = "0.1.127"
|
version = "0.1.128"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"serde",
|
"serde",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard-agent"
|
name = "cm-dashboard-agent"
|
||||||
version = "0.1.127"
|
version = "0.1.128"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@ -218,9 +218,9 @@ impl DiskCollector {
|
|||||||
raw_paths
|
raw_paths
|
||||||
};
|
};
|
||||||
|
|
||||||
// For SnapRAID setups, also include parity drives as part of the pool
|
// For SnapRAID setups, include parity drives that are related to this pool's data drives
|
||||||
let snapraid_parity_paths = self.discover_snapraid_parity_drives()?;
|
let related_parity_paths = self.discover_related_parity_drives(&member_paths)?;
|
||||||
member_paths.extend(snapraid_parity_paths);
|
member_paths.extend(related_parity_paths);
|
||||||
|
|
||||||
// Categorize as data vs parity drives
|
// Categorize as data vs parity drives
|
||||||
let (data_drives, parity_drives) = match self.categorize_pool_drives(&member_paths) {
|
let (data_drives, parity_drives) = match self.categorize_pool_drives(&member_paths) {
|
||||||
@ -244,14 +244,36 @@ impl DiskCollector {
|
|||||||
Ok(pools)
|
Ok(pools)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Discover SnapRAID parity drives
|
/// Discover parity drives that are related to the given data drives
|
||||||
fn discover_snapraid_parity_drives(&self) -> Result<Vec<String>> {
|
fn discover_related_parity_drives(&self, data_drives: &[String]) -> Result<Vec<String>> {
|
||||||
let mount_devices = self.get_mount_devices()?;
|
let mount_devices = self.get_mount_devices()?;
|
||||||
let parity_paths: Vec<String> = mount_devices.keys()
|
let mut related_parity = Vec::new();
|
||||||
.filter(|path| path.contains("parity"))
|
|
||||||
.cloned()
|
// Find parity drives that share the same parent directory as the data drives
|
||||||
.collect();
|
for data_path in data_drives {
|
||||||
Ok(parity_paths)
|
if let Some(parent_dir) = self.get_parent_directory(data_path) {
|
||||||
|
// Look for parity drives in the same parent directory
|
||||||
|
for (mount_point, _device) in &mount_devices {
|
||||||
|
if mount_point.contains("parity") && mount_point.starts_with(&parent_dir) {
|
||||||
|
if !related_parity.contains(mount_point) {
|
||||||
|
related_parity.push(mount_point.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(related_parity)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get parent directory of a mount path (e.g., "/mnt/disk1" -> "/mnt")
|
||||||
|
fn get_parent_directory(&self, path: &str) -> Option<String> {
|
||||||
|
if let Some(last_slash) = path.rfind('/') {
|
||||||
|
if last_slash > 0 {
|
||||||
|
return Some(path[..last_slash].to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Categorize pool member drives as data vs parity
|
/// Categorize pool member drives as data vs parity
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard"
|
name = "cm-dashboard"
|
||||||
version = "0.1.127"
|
version = "0.1.128"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard-shared"
|
name = "cm-dashboard-shared"
|
||||||
version = "0.1.127"
|
version = "0.1.128"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user