mirror of
https://codeberg.org/Toasterson/solstice-ci.git
synced 2026-04-10 13:20:41 +00:00
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 <toasterson@gmail.com>
This commit is contained in:
parent
a6ed0f0c69
commit
f1d161655f
2 changed files with 9 additions and 5 deletions
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "orchestrator"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
edition = "2024"
|
||||
build = "build.rs"
|
||||
|
||||
|
|
|
|||
|
|
@ -464,15 +464,20 @@ async fn discover_guest_ip_virsh(domain: &str, timeout: Duration) -> Option<Stri
|
|||
let path = format!("/var/lib/libvirt/dnsmasq/{}.leases", net);
|
||||
let content_opt = task::spawn_blocking(move || std::fs::read_to_string(path)).await.ok().and_then(|r| r.ok());
|
||||
if let Some(content) = content_opt {
|
||||
let mut best_ip: Option<String> = 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::<i64>().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 <network>
|
||||
|
|
@ -487,7 +492,6 @@ async fn discover_guest_ip_virsh(domain: &str, timeout: Duration) -> Option<Stri
|
|||
}
|
||||
}
|
||||
}
|
||||
if let Some(ip) = parse_ipv4_from_text(&att_leases.stdout) { debug!(domain=%domain, method="net-dhcp-leases-any", ip=%ip, "discovered IP"); return Some(ip); }
|
||||
}
|
||||
last_attempts.push(att_leases);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue