feat(runner): opt-in remote cancel on controller wait-timeout (#6891)#6898
Merged
Conversation
When the controller's runner-exec wait budget expires it mirrors the remote job but leaves it running, which keeps the rig lock held and wedges later runs (#6891). Add an opt-in, off by default, that best-effort cancels the remote job on wait-timeout via the existing runner_job_cancel primitive. - New env `HOMEBOY_RUNNER_CANCEL_ON_WAIT_TIMEOUT` (truthy: 1/true/yes/on). Off/unset preserves byte-identical default behavior. - `daemon_job_wait_timeout` (shared by daemon + reverse-broker timeout paths) attempts the cancel only when opted in, captures success/failure best-effort, and reflects it in the error message, `cancel_on_wait_timeout` detail, and hints. - Default path is unchanged: message still says the remote job "was not cancelled" and no cancel call is made (`timeout_mirrors_remote_job_without_cancelling` green). - Test-only injectable cancel hook lets the opt-in path be asserted without a live runner. New tests cover: opt-in fires cancel once for the job; opt-in off never calls cancel; opt-in surfaces a cancel failure. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #6891 (the deferred remote-cancel half; the lock-reclaim half merged as #6895).
Problem
When the controller's runner-exec wait budget expires, it mirrors the remote job and returns a timeout but leaves the remote job running — by deliberate design. The orphaned job keeps holding its rig lock, which wedges all later runs of that rig with
rig.resource_conflict(the #6891 symptom: a 28-min idle bench still heldstatic-site-fixture-matrix).This is intentional default behavior, covered by the contract test
timeout_mirrors_remote_job_without_cancellingand the "still in flight, not cancelled" handoff semantics. The goal is to let an operator opt in to cancelling the remote job on timeout, without changing the default.Change
HOMEBOY_RUNNER_CANCEL_ON_WAIT_TIMEOUT(truthy spellings:1/true/yes/on; unset/anything else = off).daemon_job_wait_timeout— the single shared timeout builder used by both the direct-daemon and reverse-broker wait loops — now calls the existingrunner_job_cancelprimitive (hits the daemon/broker/jobs/{id}/cancel) only when opted in, best-effort. The remote job is cancelled and its rig lock freed.disabled/requested/failed) is surfaced in the error message, the newcancel_on_wait_timeoutdetail, and a dedicated hint. A failed best-effort cancel never masks the underlying timeout.Default preserved (byte-identical)
With the opt-in off:
the remote job is still in flight and was not cancelled.detail.cancel_on_wait_timeout = "disabled".timeout_mirrors_remote_job_without_cancellingand all existing handoff-contract tests stay green.Tests
A test-only injectable cancel hook lets the opt-in path be asserted without a live runner:
opt_in_cancels_remote_job_on_wait_timeout— flag on: cancel fires exactly once for the job; message reflects cancellation.opt_in_off_leaves_remote_job_uncancelled— flag off: injected cancel is never called; default message intact.opt_in_surfaces_remote_cancel_failure_on_wait_timeout— flag on + cancel errors: timeout still surfaces with afailedoutcome and remediation hint.cargo buildclean (pre-existing warnings only);cargo test --lib runner::execution→ 76 passed, 0 failed.AI assistance
🤖 Generated with Claude Code