fix(foreman): report gate Job DeadlineExceeded as GATE-ERROR and make the gate deadline settable (#1748) - #1751
Merged
Defilan merged 1 commit intoSep 2, 2026
Conversation
… the gate deadline settable (defilantech#1748) The verify gate's per-hunk mutation pass can outlive the fixed 1800 s Job activeDeadlineSeconds (internal/controller takes ~5 min per run, so a routine controller change with dozens of hunks needs hours). The Job is killed mid-pass, and run_gate_job mapped that kill to GATE-FAIL because it only read Job.Status.Failed, so a branch whose bite check passed was reported as a failing gate. pollForTerminal now walks job.Status.Conditions for a Failed condition whose Reason is DeadlineExceeded (batchv1.JobReasonDeadlineExceeded) and returns GATE-ERROR instead. A timeout is a gate infrastructure problem (retryable), not a failing test, and the distinction decides whether the Workload retries, escalates, or marks the branch bad. The summary names the deadline and, once Execute has the log tail, is suffixed with " during <phase>" where <phase> is the last "=== <phase> ===" header, so an operator sees whether the Job survived the standard checks and stalled in a long pass (e.g. per-hunk mutation coverage). The gate deadline is now settable from the verifier Agent: a new GateActiveDeadlineSeconds field on tools.ToolDeps threads agent.Spec.Execution.ActiveDeadlineSeconds (already honoured by the coder Job) into RunGateJobToolConfig.ActiveDeadlineSeconds. Unset keeps the 1800 s default; PollTimeout keeps deriving as twice the deadline. Refs defilantech#1748 Signed-off-by: Foreman Bot <chris@mahercode.io>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Member
Author
|
Human review of the Foreman branch. Approve, pending finalize. Read the whole diff against the decided design in #1748 and ran
Two notes, neither blocking:
To put it to use on the lab fleet after merge: roll the foreman-agent image, then give the verifier Finalization: the commit is bot-signed. |
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.
What
Two changes to the verify gate's
run_gate_jobtool. A gate Job killed by itsactiveDeadlineSecondsnow maps to GATE-ERROR instead of GATE-FAIL, with a summary that names the deadline and the phase the Job was in (gate Job exceeded its 1800s deadline during per-hunk mutation coverage (base=...)). And the deadline is settable: the verifying Agent'sspec.execution.activeDeadlineSecondsis threaded throughToolDeps.GateActiveDeadlineSecondsintoRunGateJobToolConfig.ActiveDeadlineSeconds, with unset keeping the 1800 s default.Why
Refs #1748
wl-1725-agw-pool-refspassed its bite check, entered the per-hunk mutation pass oninternal/controller(39 hunks at about five minutes of envtest each), and was killed at 1800 s.pollForTerminalreadJob.Status.Failed >= 1and reported GATE-FAIL, so a branch whose checks were passing was recorded as a failing gate and its review cascade-failed. Nothing could raise the deadline without a code change. A timeout is a gate infrastructure problem, not a failing test, and the verdict decides whether the Workload treats the branch as bad.How
gateJobDeadlineExceededwalks the Job's conditions forJobFailedwith reasonDeadlineExceeded, the shape the Kubernetes Job controller sets on a deadline kill; every other failure reason keeps GATE-FAIL.pollForTerminalreturns adeadlineHitflag, andExecuteappends the last=== <phase> ===banner found in the log tail (lastGatePhase) so the operator can see whether the standard checks survived and where the Job stalled. Defaults are applied before polling, so the summary always names the effective deadline.The deadline wiring mirrors what
run_coder_jobalready does for the coder Job:cmd/foreman-agent/main.goreadsagent.Spec.Execution.ActiveDeadlineSeconds(*int64), clamps it toint32viagateActiveDeadlineSeconds(nil, zero and negative keep the default; values aboveMaxInt32saturate), and passes it throughToolDeps.PollTimeoutkeeps deriving as twice the deadline.Tests:
TestRunGateJob_DeadlineExceededProducesGATEERRORdrives the fake apiserver through aDeadlineExceededterminal state and asserts GATE-ERROR plus the phase suffix;TestRunGateJob_FailedProducesGATEFAILstill holds for a plain failure;TestBuildAll_ThreadsGateActiveDeadlineSecondsandTestGateActiveDeadlineSecondscover the wiring and the clamp.Not in this PR: bounding the mutation pass itself, which is #1749. To use the new knob on a fleet, roll the agent image and set
spec.execution.activeDeadlineSecondson the verifier Agent.Checklist
make testpasses locally (verify gate GATE-PASS on the branch; CI green)make lintpasses locally (CI)git commit -s) per DCO (Foreman-bot sign-off under my address; squash-merge attributes the commit to me, as with fix(foreman): clear Dispatched condition on terminal Workloads #1741)Assisted-by: Foreman (coder
dsv4-flash-coder, DeepSeek-V4-Flash-Vision-Exp on vLLM) generated the code and tests from the decided design in #1748; the verify gate ran the full check suite. I reviewed the diff by hand, ran the two packages' tests, vet and gofmt on the branch, and own the sign-off.