I blamed the issue for the machine's fault
Last week an operator opened the scheduler and found about ten issues from one project sitting in a held state. Every one of them had finished its work. Every one of them had then failed to land, twice, on the same machine, and been held for it. The scheduler had kept sending issues to that machine the whole time, and nothing had told anyone.
The cause on the machine was mundane: its main checkout had an unpushed commit that upstream had since moved past, so every fast-forward pull failed. One rebase fixed it. The cause in the design was mine, and it is the part worth writing down.
What I wrote
I wrote the landing rule to count failures per issue. A landing that stops at certain steps is retried a minute later on the same worktree, and a second stop in the same draining holds the issue with git’s reason. That rule is fine when the failure is the branch’s own doing. It is wrong when the failure belongs to the machine, because then the issue gets two strikes for a condition it had no part in, and so does the next issue, and the next.
I also wrote the only machine-level withholding we have as a closed list. If a machine refuses to start a session for reasons that are clearly its own, its slots are withheld from every work item for a while. I scoped that list to exactly the refusals the issue in front of me described. I never asked the more general question: what else can a machine fail at that is the same for every issue alike? A landing whose pull of the main checkout fails is the obvious answer, and it wasn’t on the list, so the machine stayed in the pool.
The slot rule compounded it. A slot counts when the workspace holds the issue, the container is running, the machine is online and fit, and credentials are in place. None of those conditions ask whether the checkout can actually be pulled or pushed. And the embarrassing part is that the controller already had the answer. The agent reports, with every reading, how many local commits the checkout holds that no remote branch has. We store it. Nothing in the scheduler reads it. The number the operator needed was sitting in the database the entire time.
Finally, a hold is logged as an error-severity event and nothing more. There is no alert for a held issue, a withheld machine, or a landing that keeps stopping. The operator found out by looking.
What it produced
Each issue dispatched to the machine ran to completion, failed its landing at the pull, retried a minute later, failed again, and was held. Each landing freed a slot. The spreading rule prefers the machine with the fewest running sessions, so the freed slot made that machine the most attractive target for the next issue. Ten times. Had the project held hundreds of candidates, or had one held issue gated a chain of dependents, the whole queue would have drained onto one broken checkout, one issue at a time.
What I should have written
-
Classify the failure by whose it is, not by where it happened. A landing stop caused by the main checkout rather than the worktree’s branch is the machine’s refusal, the same kind we already withhold a machine for at start. No strike toward the issue. Machine withheld from every work item with the existing back-off. Reported with the reason and until when. The per-issue hold should only ever count failures the issue’s own branch caused.
-
Make the slot conditions use what the scheduler already knows. A workspace whose checkout holds commits upstream lacks, or whose last pull failed, cannot land anything. That slot was never real, and the planner should say so among the no-slot reasons it already reports.
-
Alert on it. A withheld machine, a workspace offering no slot because of its checkout, or a hold whose reason lies outside the issue’s branch should all raise a notification that names the machine, the reason, and what the operator has to do. An error-severity event in a log is not a notification.
-
Bound the retry by the condition, not a count. A landing stopped at the pull should wait in the landing state until the checkout’s reading shows the branch back on upstream, then try again. The work is done. Nothing about it needs an operator’s release.
What I’ll do differently
The pattern I fell into is one I want to name so I recognise it next time: I wrote a general rule (machine-level withholding) to the scope of a single ticket, then wrote a neighbouring rule (per-issue strikes) without checking whether its failure modes overlapped with the first. Each rule was defensible on its own page. Together they left a hole exactly the shape of this incident.
Going forward, when I write a rule that penalises an entity for a failure, I’ll ask explicitly: could this failure have happened to any other entity in the same place? If yes, the penalty belongs to the place, not the entity. When I write a withholding or exclusion as a list, I’ll also write the principle the list is an instance of, so the next case has somewhere to go. And when I add a figure to what the agent reports, I’ll write down who consumes it; a reported number with no reader is a bug waiting for an incident to find it.
The fix is in review now. The rebase took the operator five minutes. The ten manual releases took longer, and that is the part I owe them an apology for.