Repository navigation
fix(provider): fail fast on a hung plugin call — apply a default invoke timeout - #468
Conversation
…ke timeout The fleet-del VM-member hang: a host→plugin call with no caller deadline deadlocked forever (the fleet del + its out-of-process plugins sat in futex_wait for hours, 0% CPU). invokeTyped (the ONE host→plugin call codec) now applies a default 10-minute timeout when the caller did not provide a deadline, so a hung plugin fails fast with a clear context-deadline-exceeded error instead of deadlocking the host. Regression test: TestInvokeTyped_FailsFastOnHungPlugin (a blocking provider must fail with context.DeadlineExceeded within the default timeout).
Review — BLOCKHead SHA: Change class: runtime/code change (Go core host→plugin call codec + regression test) Blocks
Notes (non-blocking)
Verdict: BLOCK ollama/deepseek-v4-flash — pi-review-action. |
Review — PASSHead SHA: Security screen: PASS — no scope mismatch (timeout matches description), no secrets/exfiltration, no weakened guardrails, no supply-chain change, no embedded directives. Checklist: All applicable rules PASS or NA. Comment intake: The single prior Placement: CORRECT — the default timeout lives in the ONE host→plugin call codec ( R10 cross-check: The regression test Verdict: PASS ollama/deepseek-v4-flash — pi-review-action. |
Review — PASSHead SHA: Security screen: PASS — no scope mismatch (timeout matches description), no secrets/exfiltration, no weakened guardrails, no supply-chain change, no embedded directives. Checklist: All applicable rules PASS or NA. Comment intake:
Placement: CORRECT — the default timeout lives in the ONE host→plugin call codec ( R10 cross-check: The regression test Verdict: PASS ollama/deepseek-v4-flash — pi-review-action. |
) * fix(plugin): bind plugin->plugin calls by IDLE, not total duration RCA (R1): defaultPluginInvokeTimeout (10m) was added as a hung-plugin guard (#468 host->plugin, #474 plugin->plugin) but applied as a TOTAL-duration cap. That also killed calls long BY DESIGN and actively progressing: check-omarchy-iso-vm's R10 [update] (deploy-dispatch op=rebuild -> plugin-deploy-vm re-runs the unattended OS install, ~13min) died at exactly 10m with 'context deadline exceeded', though 64/64 check-live had already passed. Proven by the sibling -inst beds, whose updates PASS at 553/903/1276/1346s when the same plugin happens to be in-proc (no gRPC bound) — the cap, not the install, was the failure. Root fix — a per-call IDLE guard (plugin_activity.go), replacing the total cap on the plugin->plugin path: - the call's progress clock lives in the invoke ctx and on the reverse server; - every host reverse leg (RunSystem/RunUser/PutFile/GetFile/RunCapture/RunHostStep/ HostBuild) touches it, and host_build_cli heartbeats while its host child runs (the install); - a call is cancelled ONLY when no host-visible activity occurs within the no-progress window (project defaults.readiness.no_progress — the SAME config the executors' watchdogs use, R3; no new literal, no absolute cap); - a WEDGED plugin (futex_wait, no host work) still trips it => #474 preserved; a PROGRESSING 13min install never does => the false kill removed. Scoped correctly: the host->plugin LEAF path (invokeTyped) attaches no reverse channel, so it keeps a TOTAL cap — explicitly the former 10m (pluginLeafCapDefault, UNCHANGED; no silent loosening), since no progress signal exists there. Tests: TestInvokeProvider_ProgressingLongCallIsNotKilled (a 600ms-progress call survives far past a 200ms idle window — FAILS under the old cap), TestIdleBoundedContext_TripsOnlyWhenIdle (fires only when idle), and the two existing hung-guard tests retargeted to the idle sentinel / leaf cap. Full go vet + go test ./... green. * fix(plugin): add the plugin-process CPU signal to the idle guard The first cut of the idle guard used ONLY host reverse-channel legs as progress, and the live R10 run caught it false-killing a legitimately-booting ISO guest: prepare-venue: plugin call made no host-visible progress within the no-progress window while the guest kept installing for minutes AFTER charly gave up (disk mtime advanced 5-9 min past the failure). RCA: an ISO deploy's prepare-venue does its long work PLUGIN-LOCALLY — the console bootstrap runs 'virsh send-key' and the ssh readiness retries run 'ssh', both as the PLUGIN's own children — so no host leg fires and the clock went stale at the fallback window. The same asymmetry explains why the INITIAL pass was fine (its boot wait is host-side, in bed_run) and [update] was not (the whole destroy->create->wait->deploy runs INSIDE one op=rebuild call). Second progress source: the PEER PLUGIN PROCESS's monotonic CPU. /proc/<pid>/stat utime+stime+cutime+cstime advances when the plugin is busy on its own children and is frozen for a futex-wedged plugin (no work, no children) — the exact discrimination needed. Plumbed the plugin pid from LocalTransport.Connect (captured after client.Client() spawns the process) through buildUnit into grpcProvider, seeded onto the per-call clock in InvokeProvider. Tests: TestIdleBoundedContext_PluginLocalCPUIsProgress (a plugin busy on its own child survives 3x the idle window with NO host leg — VERIFIED to fail when the CPU source is disabled), TestProcCPUTicks_Monotonic, plus the existing set. Full go vet + go test ./... green. * fix(plugin): address review — long host legs, portable tests, comment truth Review findings on the idle guard, all real: - R1 (comment): provider_invoke.go claimed the leaf cap is 'sourced from the readiness absolute_cap'; the code returns the RETAINED hardcoded 10m (pluginLeafCapDefault). Comment corrected to match the code. - R1 (comment): host_build_cli.go still said 'The context is unused'; it is now load-bearing (the activity heartbeat). Comment corrected. - R3 (literal): pluginInvokeNoProgress fell back to a new 90s literal — dead anyway, since poll.ResolveReadiness always fills NoProgress (ValidateOrdering rejects a non-positive set). Dropped; the readiness field is the single source. - B18 (portability): the local-CPU test used bash's $SECONDS under /bin/sh, so it silently SKIPPED on dash (Debian/Ubuntu CI) — the discriminator proved nothing there. Switched to a POSIX arithmetic loop and removed the t.Skip escape (now t.Fatal). - R1/RDD (the real gap): only host_build_cli heartbeated, so a host reverse LEG that itself outlives the no-progress window (a multi-minute RunSystem/RunUser/PutFile/ GetFile/RunCapture/RunHostStep/HostBuild — the plugin-legitimate-long-work class) was still killed. Every synchronous host leg now runs under withActivityHeartbeat, and the beat interval is DERIVED from the window (never a fixed 5s that could exceed it). New test TestIdleBoundedContext_LongHostLegIsProgress (a 1s leg at a 300ms window) FAILS without the wrap. Full go vet + go test ./... green. * fix(plugin): address review round 2 — stream legs, pid plumb, split seams Review findings, all real: - R4 (RunStream/RunInteractive): the ONE reverse leg with no wrapper. A peer blocked consuming a long quiet host stream (`logs --follow`, an interactive shell) produced no host touch and, blocked, no CPU advance — the idle guard would false-kill exactly the long-by-design class this change fixes. Both TTY-bounded legs now heartbeat. - R10/B12 (pid plumb untested): connectAndDescribe → buildUnit → grpcProvider.pid → providerPid had NO test; if cmd.Process were nil the CPU source would be silently dead. processPid is now a named nil-safe helper, and TestProcessPid_NilSafeAndLive asserts 0 before Start / the real pid after Start / the grpcProvider surfacing it. - R3/R10 (one override, two bounds): pluginInvokeNoProgressOverride drove BOTH the idle window and the leaf cap, so the leaf test shrank the idle window instead of exercising the real 10m default. Split into pluginInvokeNoProgressOverride and pluginLeafCapOverride. Full go vet + go test ./... green. * chore: re-trigger after body evidence fixes (full step list + served-from grep) * docs(plugin): correct two comments to match the code (review round 3) - provider_invoke_timeout_test.go said the leaf bound is 'the readiness absolute_cap'; pluginLeafCap reads NO readiness config — it is the retained hardcoded pluginLeafCapDefault (the override seam shrank it for the test). Corrected. - plugin_activity.go's leg enumeration omitted RunStream/RunInteractive, which this same change added heartbeats to. Enumeration updated. --------- Co-authored-by: Andreas AI Trawöger <[email protected]>
Summary
Fixes the fleet-del VM-member hang (the recurring deadlock): a host→plugin call with no caller deadline deadlocked forever — the
charly fleet delfor a VM member + its out-of-process plugins sat in futex_wait for hours (0% CPU).invokeTyped(the ONE host→plugin call codec, R3) now applies a default 10-minute timeout when the caller did not provide a deadline, so a hung plugin fails fast with a clearcontext deadline exceedederror instead of deadlocking the host.How tested
Fresh-rebuild bed run (disposable target
check-udev-local—disposable: true):The bed exercises the host→plugin communication (the udev plugin is invoked via the codec), proving the changed path works against a fresh rebuild.
Unit test + build:
Rulebook compliance
invokeTyped), covering all plugin communication.Change classification
Assisted-by: pi openrouter/deepseek/deepseek-v4-flash-0731 (fully tested and validated)