Repository navigation
fix(platform): bound video toolchain provisioning and its children - #4079
Conversation
The live YouTube test's self-provisioner had no deadline on its downloads or on the children it spawned, and the 600 s hook timeout rejected without cancelling either: a stalled apt-get held the required Unit job for ten minutes and outlived the suite. Each stage now runs under its own deadline, capped by a 540 s run budget that stays below the hook timeout, which is now derived from it. A download aborts its request. A child is stopped through its own process group, the runYtdlp shape: SIGTERM, SIGKILL after a 5 s grace, and SIGKILL for anything it left behind. Only processes the helper started are touched. The rejection names the stage, its elapsed time and its deadline, and the "ffmpeg not found" error carries the install stage's failure. The apt install runs `sudo -n`, because a password prompt is a wait with no deadline.
A download that fails outright (DNS, reset, a full disk) rejected with the runtime's bare "fetch failed", which names no stage. It now rejects as the stage's VideoToolchainError, with the original error as its cause. A failed kill after the deadline (EPERM) emits 'error' on the child, which was read as a failed start. It is now logged, and the bounded wait for 'close' goes on.
|
Independent review: accepted at
Verdict: this meets #4073.
Local checks on the exact head, synthetic only, with no network, apt or brew
CI at the exact head (merge ref
Non-blocking (P3)
Not covered: no real apt or brew run locally. The live provisioning evidence is CI's. No production contact. |
|
Root merge acceptance at unchanged head Distinct native review: agent #2, run 9fd4795d, separate from author agent #5 / run 3b5dab6d. Root read the three-file change and the detailed review. The local synthetic stalled-lookup and mutant evidence belongs to that reviewer; the live provisioning execution belongs to CI. The original Backend integration job 110803014512 remains a recorded failure (1320/1321, RAG lock timing). Root requested exactly one normal rerun of that failed job on the same head, without an empty commit. Checks attempt 2, replacement job 110817119162, freshly executed and passed 1321/1321 checks across 214/214 lanes. Current-head rollup: 50 success, 11 intentional skips and 1 neutral Trivy; no pending/failed check. Skipped/neutral outcomes are not counted as executed passes. The accepted scope is bounded provisioning and cleanup of the original child process group. Escaped descendants and truthful cleanup diagnostics remain #4084; the realistic privileged apt variant needs local proof. Neither this rerun nor this merge resolves that residual. Existing #4010 remains separate. Normal protected squash merge only, matching the exact accepted head, followed by main CI and the ordinary release gate. |
What changed
services/platform/backend/core/video_links/ytdlp_toolchain.ts(the live YouTube test's self-provisioner, also used by the dev engine's "Video toolchain" step) had no bound on any stage:downloadTocalledfetchand thenarrayBuffer()with no deadline;runandwhichspawned children with no deadline and never killed them;beforeAlltimeout inytdlp_live.test.tsrejected the hook but cancelled none of this.In Unit job 110740061610 (PR #4072) a stalled
sudo apt-get install -y ffmpegtherefore held the required job for ten minutes and lived on as a hanging process.Now:
VIDEO_TOOLCHAIN_DEADLINESsets each stage's bound: download response 30 s, download body 120 s,whichlookup 10 s,unzip60 s, package install 420 s.ProvisioningClockcaps every stage by what is left of the 540 s run budget.totalMs + 60 s(= 600 s, unchanged), derived from the budget. So a stall fails inside provisioning, naming its stage, before the hook times out.AbortControllercovers the request in two phases,<stage> responseand then<stage> body. Expiry aborts it with the stage's error.spawnBounded) follow theytdlp.ts:runYtdlpshape:detached, so the child runs in its own process group;process.kill(-pid)sends SIGTERM, then SIGKILL after a 5 s grace;close, or, if even SIGKILL brings noclose, after one more grace, saying so.VideoToolchainErrorcarriesstage, and its message reads, for example,[video-toolchain] yt-dlp download body: timed out after 120000 ms (deadline 120000 ms).sudo -n. A password prompt is a wait with no deadline, and the group-isolated child has no terminal, so it fails at once and the error says why.whichstill answersnullfor "not found", but now rejects when the lookup itself overruns its deadline.Live-ingestion coverage is unchanged: the gated live suite and its bot-wall-only skip are untouched. A provisioning failure still fails the hook, as a named stage instead of an anonymous timeout. Nothing is skipped or turned into a pass, and no timeout was enlarged.
Finding → commit → test
ytdlp_toolchain.test.ts)551f8ca5frejects a body that stops arriving, naming the body stage551f8ca5frejects a server that never answers, naming the response stage551f8ca5fstops a stalled child and everything it started, then names the stage551f8ca5fescalates to SIGKILL when the child ignores SIGTERM551f8ca5fstops what a stopped child left behind in its group551f8ca5fleaves processes it did not start alone(bystanders in the worker's group and in their own group)551f8ca5frejects a stalled ffmpeg lookup by its stage and stops the lookup,caps every stage by the rest of the provisioning budget551f8ca5f'sh -c exit 3' exited 3), unstartable command, full success throughprovisionToolchainfetch failed1a9620772names the stage when the connection itself fails1a9620772close(not reproducible without a foreign-uid process)Every case is synthetic: a loopback HTTP stub and fake
shchildren. There are no real downloads, no apt and no network.Verification
Failing on
main(09d0b20d2). The new test file cannot import onmain, because the seams do not exist there. So the behaviour was reproduced through the publicensureVideoToolchain()alone. The repro is a throwaway test, not committed, using:whichonPATHthat sleeps and records its pid and its child's pid;fetchredirected to a loopback stub whose body stalls.Passing on the head:
Mutations (each restored afterwards):
child.kill: 6 of the 13 tests of the first commit fail. These are every grandchild check plus the bystander test.stops what a stopped child left behind in its groupfails.ytdlp_toolchain.tsat551f8ca5f(before the follow-up):names the stage when the connection itself failsfails withgot 'fetch failed'.Concept sweep
scripts/dev-engine.ts(the "Video toolchain" step) callsensureVideoToolchain()and printserr.messagethroughexternalToolchainsUnavailable. Its warning now names the failing stage.bun devboot with no bound; it is now bounded by the same budget.ytdlp.test.tsimports onlyBGUTIL_PLUGIN_NEST_DIRandbgutilPluginInstallDir, which are unchanged.Not in this slice
The root cause of the apt stall is still unknown. Resolving ffmpeg before the hook would remove the heavy system install from the test entirely: either a Unit-job install step with a cache key, or honouring a pre-set
VIDEO_INGEST_FFMPEG_LOCATIONas an explicit input. That needs a.github/workflowschange, which this token cannot push. The same applies to #4010's backend-integration "Install ffmpeg" step. This PR gives the helper-path half of #4010 its diagnostics: stage, elapsed time, deadline.Closes #4073
Refs #4010