From f1d161655f5b3eeeeb39491d34b0d895c94cb92513349e1143eec5741fdeda75 Mon Sep 17 00:00:00 2001 From: Till Wegmueller Date: Mon, 17 Nov 2025 22:00:46 +0100 Subject: [PATCH] Refactor `dnsmasq` leases-based guest IP discovery and bump version to 0.1.8 - Update IP selection logic to prefer the latest lease based on epoch timestamp. - Remove redundant IP discovery logic in `net-dhcp-leases`. - Increment orchestrator version to 0.1.8 for release. Signed-off-by: Till Wegmueller --- crates/orchestrator/Cargo.toml | 2 +- crates/orchestrator/src/scheduler.rs | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/orchestrator/Cargo.toml b/crates/orchestrator/Cargo.toml index bec6f5c..74d294f 100644 --- a/crates/orchestrator/Cargo.toml +++ b/crates/orchestrator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "orchestrator" -version = "0.1.7" +version = "0.1.8" edition = "2024" build = "build.rs" diff --git a/crates/orchestrator/src/scheduler.rs b/crates/orchestrator/src/scheduler.rs index 9fe0289..42193ca 100644 --- a/crates/orchestrator/src/scheduler.rs +++ b/crates/orchestrator/src/scheduler.rs @@ -464,15 +464,20 @@ async fn discover_guest_ip_virsh(domain: &str, timeout: Duration) -> Option = None; + let mut best_epoch: i64 = -1; for line in content.lines() { // Format: epoch MAC IP hostname clientid let parts: Vec<&str> = line.split_whitespace().collect(); if parts.len() >= 3 && parts[1].eq_ignore_ascii_case(mac_s.as_str()) { - let ip = parts[2].to_string(); - debug!(domain=%domain, method="dnsmasq.leases", ip=%ip, "discovered IP"); - return Some(ip); + let epoch: i64 = parts[0].parse::().unwrap_or(0); + if epoch > best_epoch { + best_epoch = epoch; + best_ip = Some(parts[2].to_string()); + } } } + if let Some(ip) = best_ip { debug!(domain=%domain, method="dnsmasq.leases", ip=%ip, "discovered IP"); return Some(ip); } } } // 2b) Try virsh net-dhcp-leases @@ -487,7 +492,6 @@ async fn discover_guest_ip_virsh(domain: &str, timeout: Duration) -> Option