Watch
0
0
Fork
You've already forked hyperhive
0

a failed container start shows the unit's own journal lines in the op output

This commit is contained in:
atlas 2026-11-01 16:33:26 +01:00 • committed by mara
commit 9a773349a8

View file

@ -799,16 +799,23 @@ fn make_log_callback(
/// Put a failed non-streaming op's error into its build-log row, which has no
/// other output: `start` runs through `call`, not the streaming protocol. The
/// error carries `nixos-container`'s stderr.
/// error carries `nixos-container`'s stderr; `journal` is the container
/// unit's own log from hive-priv. An `Err` there (an older hive-priv does not
/// know the op) leaves the stderr alone.
fn record_failure(
logs: Option<&crate::build_logs::BuildLogs>,
log_id: Option<i64>,
err: &anyhow::Error,
journal: Result<String>,
) {
if let (Some(h), Some(id)) = (logs, log_id) {
for line in format!("{err:#}").lines() {
h.append_stderr(id, line);
}
match journal {
Ok(text) => text.lines().for_each(|l| h.append_stderr(id, l)),
Err(e) => tracing::debug!(error = ?e, "start journal unavailable"),
}
}
}
@ -879,9 +886,13 @@ async fn priv_run_inner(
None => Err(missing_toplevel(kind, name)),
},
"start" => {
let attempt = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.map_or(0, |d| d.as_secs());
let started = crate::priv_client::start_container(name).await;
if let Err(e) = &started {
record_failure(logs.as_deref(), log_id, e);
let journal = crate::priv_client::start_failure_log(name, attempt).await;
record_failure(logs.as_deref(), log_id, e, journal);
}
started
}