From b76ab2a5c4b75b322ff564f59decc6b5c3c24dd3 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Sat, 21 Nov 2026 17:49:00 -0600 Subject: [PATCH 1/3] fix(onnxruntime): fetch 1.31.1 source from developing-today-forks mirror microsoft/onnxruntime returns 404 on GitHub since 2026-11-18, so the pinned fetchFromGitHub source can no longer be fetched and fleet-smoke on main has been red. Fetch the identical tree (same NAR hash) from the developing-today-forks/onnxruntime-src v1.31.1 release instead. Fixes #12247 Co-Authored-By: Claude Opus 5.5 --- pkgs/atlas-search/onnxruntime/default.nix | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/pkgs/atlas-search/onnxruntime/default.nix b/pkgs/atlas-search/onnxruntime/default.nix index 1459305cd..8ef30de7f 100644 --- a/pkgs/atlas-search/onnxruntime/default.nix +++ b/pkgs/atlas-search/onnxruntime/default.nix @@ -32,6 +32,7 @@ config, stdenv, fetchFromGitHub, + fetchzip, abseil-cpp, buildPackages, cmake, @@ -152,11 +153,16 @@ effectiveStdenv.mkDerivation (finalAttrs: { pname = "onnxruntime"; version = "1.31.1"; - src = fetchFromGitHub { - owner = "microsoft"; - repo = "onnxruntime"; - tag = "v${finalAttrs.version}"; - fetchSubmodules = true; + # microsoft/onnxruntime returns 404 on GitHub since 2026-11-18 + # (code#12247), so the v1.31.1 tag (with submodules) can no longer be + # fetched upstream. The identical source tree is published as a + # release asset in developing-today-forks/onnxruntime-src; the NAR + # hash is unchanged from the upstream fetchFromGitHub pin, so the + # build is the same. To bump `version`, publish the new tag's source + # (submodules included) there first. + src = fetchzip { + name = "source"; + url = "https://github.com/developing-today-forks/onnxruntime-src/releases/download/v${finalAttrs.version}/onnxruntime-${finalAttrs.version}-src.tar.xz"; hash = "sha256-wATnI1v3De6+41fGYWS2458TCUWhBECNw2kBnfajKEo="; }; From 20633374a936b6d1ea9ab1c90fa0460a2ed416bb Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Sat, 21 Nov 2026 18:55:02 -0600 Subject: [PATCH 2/3] ci(fleet-smoke): allow 150 minutes for a cold onnxruntime build With the onnxruntime output evicted from the Actions cache, the build step compiles onnxruntime 1.31.1 from source and the 60 minute job limit cancels it before fleet builds. Warm runs still take about 40m. Refs #12247 Co-Authored-By: Claude Opus 5.5 --- .github/workflows/fleet-smoke.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/fleet-smoke.yml b/.github/workflows/fleet-smoke.yml index 52224d9c8..c6d7677c6 100644 --- a/.github/workflows/fleet-smoke.yml +++ b/.github/workflows/fleet-smoke.yml @@ -47,7 +47,9 @@ jobs: fleet-smoke: name: "basic: fleet per-variant smoke suite" runs-on: ubuntu-latest - timeout-minutes: 60 + # A cold Nix cache compiles onnxruntime from source (#12247), which + # alone runs past an hour on a hosted runner; warm runs take ~40m. + timeout-minutes: 150 steps: - uses: actions/checkout@v7 From b04498c16d2eda5b209cd476c93d5a9307ee693d Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Sat, 21 Nov 2026 20:00:40 -0600 Subject: [PATCH 3/3] fix(fleet-queue): bind the queue broker before its Turso backend comes up Since the Turso switch (be0d2b9f34) the broker resolved the Turso token with a 30s retry and ensured the schema before binding, so in the hermetic fleet-smoke (secrets broker on a dead port) it never bound: /healthz and repo-queue health failed (2 of 100 smoke checks). The failure stayed hidden while the onnxruntime fetch kept the build red. The broker now binds first and brings the backend up on a startup thread. /healthz and /validate answer at once; queue verbs answer exit 3 with the latest startup error until the backend is ready. If the backend cannot come up within the 30s budget the broker still exits 3, so supervisors restart it as before. Refs #12247 Co-Authored-By: Claude Opus 5.5 --- .../crates/fleet-queue/src/queue_broker.rs | 184 ++++++++++++------ 1 file changed, 124 insertions(+), 60 deletions(-) diff --git a/pkgs/fleet/crates/fleet-queue/src/queue_broker.rs b/pkgs/fleet/crates/fleet-queue/src/queue_broker.rs index ac54eca5a..caefd4ba5 100644 --- a/pkgs/fleet/crates/fleet-queue/src/queue_broker.rs +++ b/pkgs/fleet/crates/fleet-queue/src/queue_broker.rs @@ -32,7 +32,12 @@ struct State { secrets_url: String, secrets_token: String, agent: ureq::Agent, - turso: crate::turso_queue::TursoBackend, + /// Filled by the startup thread once the Turso token resolves and + /// the schema is ensured (#12247); until then queue verbs answer + /// exit 3 with `turso_pending`. + turso: std::sync::OnceLock, + /// Why the backend is not ready yet: the latest startup failure. + turso_pending: Mutex, } /// The queue broker's secrets-by-name source: a direct HTTP call to @@ -554,7 +559,15 @@ fn dispatch(st: &State, path: &str, req: &Value) -> Value { } "/healthz" => ok(json!({"service": "queue-broker"})), _ => { - let resp = crate::turso_queue::dispatch(&st.turso, path, req); + let Some(turso) = st.turso.get() else { + let why = st + .turso_pending + .lock() + .map(|g| g.clone()) + .unwrap_or_default(); + return fail(3, format!("queue backend not ready: {why}")); + }; + let resp = crate::turso_queue::dispatch(turso, path, req); // #8568: the broker-side needs-drew raise for an // escalated block (fire-and-forget). if path == "/block" { @@ -694,70 +707,27 @@ pub fn run() -> i32 { return 3; } } - let turso = { - let url = std::env::var("QUEUE_BROKER_TURSO_URL") - .unwrap_or_else(|_| crate::turso_queue::DEFAULT_TURSO_URL.to_string()); - let token = match std::env::var("QUEUE_BROKER_TURSO_TOKEN_FILE") { - Ok(f) => match crate::token_file::load_token_file(&f) { - Ok(v) => v, - Err(e) => { - crate::log::info("queue-broker", &e); - return 3; - } - }, - Err(_) => { - let resolver = Resolver::new(vec![Box::new(DirectSecrets { - url: secrets_url.clone(), - token: secrets_token.clone(), - agent: agent.clone(), - })]); - match resolve_with_startup_retry( - &resolver, - crate::turso_queue::TURSO_TOKEN_SECRET_NAME, - Duration::from_secs(30), - ) { - Ok(v) => v.expose().to_string(), - Err(e) => { - crate::log::info( - "queue-broker", - &format!( - "turso backend token resolve failed after 30s of retries: {e}" - ), - ); - return 3; - } - } + // A Turso token file, when named, is a local config read: a + // missing or unreadable file stays a startup config error. + let turso_url = std::env::var("QUEUE_BROKER_TURSO_URL") + .unwrap_or_else(|_| crate::turso_queue::DEFAULT_TURSO_URL.to_string()); + let turso_token_from_file = match std::env::var("QUEUE_BROKER_TURSO_TOKEN_FILE") { + Ok(f) => match crate::token_file::load_token_file(&f) { + Ok(v) => Some(v), + Err(e) => { + crate::log::info("queue-broker", &e); + return 3; } - }; - let mut backend = crate::turso_queue::TursoBackend::new(url, token, agent.clone()); - // #8276: the dep rechecker's GitHub window, authenticated - // by name through the same secrets Resolver as the Turso - // token above. - backend.set_gh_probe(Arc::new(GhDepProbe { - secrets_url: secrets_url.clone(), - secrets_token: secrets_token.clone(), - agent: agent.clone(), - token: Mutex::new(None), - })); - if let Err(e) = backend.ensure_schema() { - crate::log::info( - "queue-broker", - &format!("turso backend schema ensure failed: {e}"), - ); - return 3; - } - crate::log::info( - "queue-broker", - &format!("queue backend: turso ({})", backend.url()), - ); - backend + }, + Err(_) => None, }; let state = Arc::new(State { secrets_url, secrets_token, agent, - turso, + turso: std::sync::OnceLock::new(), + turso_pending: Mutex::new("starting".to_string()), }); let server = match Server::http(&bind) { @@ -769,6 +739,31 @@ pub fn run() -> i32 { }; crate::log::info("queue-broker", &format!("listening on {bind}")); + // #12247: bind first, then bring the Turso backend up on a + // startup thread, so /healthz and /validate answer at once and + // queue verbs answer exit 3 with the latest startup error until + // the backend is ready. A backend that cannot come up within the + // retry budget still exits the broker with 3, so a supervisor + // restarts it exactly as when the backend came up before bind. + { + let st = Arc::clone(&state); + std::thread::spawn(move || { + match start_turso_backend(&st, turso_url, turso_token_from_file) { + Ok(backend) => { + crate::log::info( + "queue-broker", + &format!("queue backend: turso ({})", backend.url()), + ); + let _ = st.turso.set(backend); + } + Err(e) => { + crate::log::info("queue-broker", &e); + std::process::exit(3); + } + } + }); + } + // Dual-bind (#6216): the same handler over a Unix socket. A bind // failure or a live owner degrades to TCP only, never to exit: // the TCP listener is the established surface. @@ -1171,6 +1166,71 @@ mod tests { } } +/// The Turso backend's startup (#12247), run after bind: the token +/// (from the named file, or by name from the secrets broker within +/// the startup retry budget), the dep probe (#8276) and the schema. +/// Each failure is recorded in `turso_pending`, so a queue verb that +/// arrives first reports why the backend is not ready. +fn start_turso_backend( + st: &State, + url: String, + token_from_file: Option, +) -> Result { + let note = |why: String| { + if let Ok(mut pending) = st.turso_pending.lock() { + *pending = why; + } + }; + let token = match token_from_file { + Some(token) => token, + None => { + let resolver = Resolver::new(vec![Box::new(DirectSecrets { + url: st.secrets_url.clone(), + token: st.secrets_token.clone(), + agent: st.agent.clone(), + })]); + match resolve_with_startup_retry_observed( + &resolver, + crate::turso_queue::TURSO_TOKEN_SECRET_NAME, + Duration::from_secs(30), + |e| note(format!("turso backend token resolve: {e}")), + ) { + Ok(v) => v.expose().to_string(), + Err(e) => { + let msg = + format!("turso backend token resolve failed after 30s of retries: {e}"); + note(msg.clone()); + return Err(msg); + } + } + } + }; + let mut backend = crate::turso_queue::TursoBackend::new(url, token, st.agent.clone()); + // #8276: the dep rechecker's GitHub window, authenticated by name + // through the same secrets broker as the Turso token above. + backend.set_gh_probe(Arc::new(GhDepProbe { + secrets_url: st.secrets_url.clone(), + secrets_token: st.secrets_token.clone(), + agent: st.agent.clone(), + token: Mutex::new(None), + })); + if let Err(e) = backend.ensure_schema() { + let msg = format!("turso backend schema ensure failed: {e}"); + note(msg.clone()); + return Err(msg); + } + Ok(backend) +} + +#[cfg(test)] +fn resolve_with_startup_retry( + resolver: &Resolver, + name: &str, + budget: Duration, +) -> Result { + resolve_with_startup_retry_observed(resolver, name, budget, |_| {}) +} + /// Resolve `name` through `resolver`, retrying until `budget` /// elapses. Startup only: a co-hosted or freshly started /// secrets-broker binds before its first vault refresh completes @@ -1178,16 +1238,20 @@ mod tests { /// races its readiness and the whole serve list exits (#8394 /// Codex P2). Bounded: once the budget is spent the last error is /// returned and the caller fails exactly as the one-shot did. -fn resolve_with_startup_retry( +/// Each failed attempt is passed to `observe` (#12247), so the +/// broker can say why its backend is not ready yet. +fn resolve_with_startup_retry_observed( resolver: &Resolver, name: &str, budget: Duration, + observe: impl Fn(&SecretError), ) -> Result { let deadline = std::time::Instant::now() + budget; loop { match resolver.resolve(name) { Ok(v) => return Ok(v), Err(e) => { + observe(&e); if std::time::Instant::now() >= deadline { return Err(e); }