Watch
0
0
Fork
You've already forked hyperhive
0

swarm-builder: log each archetype eval's elapsed time, wait 5 minutes

This commit is contained in:
atlas 2026-10-25 18:20:41 +01:00 • committed by mara
commit cce00a6592

View file

@ -346,16 +346,22 @@ async fn read_tail(
/// The last [`TAIL_LINES`] lines of `stderr`, at most [`TAIL_BYTES`] bytes,
/// or the exit status when it said nothing.
pub(crate) fn tail(stderr: &str, status: std::process::ExitStatus) -> String {
last_lines(stderr).unwrap_or_else(|| format!("nix exited with {status} and printed nothing"))
}
/// The last [`TAIL_LINES`] non-blank lines of `stderr`, at most [`TAIL_BYTES`]
/// bytes; `None` when it has none.
pub(crate) fn last_lines(stderr: &str) -> Option<String> {
let lines: Vec<&str> = stderr.lines().filter(|l| !l.trim().is_empty()).collect();
if lines.is_empty() {
return format!("nix exited with {status} and printed nothing");
return None;
}
let joined = lines[lines.len().saturating_sub(TAIL_LINES)..].join("\n");
let mut start = joined.len().saturating_sub(TAIL_BYTES);
while !joined.is_char_boundary(start) {
start += 1;
}
joined[start..].to_owned()
Some(joined[start..].to_owned())
}
#[cfg(test)]