swarm-builder: log each archetype eval's elapsed time, wait 5 minutes
This commit is contained in:
parent
b79896c237
commit
cce00a6592
1 changed files with 195 additions and 24 deletions
|
|
@ -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)]
|
||||
|
|
|
|||
Loading…
Reference in a new issue