fix: passing failures (the network) are retried, in the app and by the farm #43

Merged
HumanBean merged 1 commit from HumanBean/Beanstalk:fix/retries into main 2026-11-16 02:46:42 +00:00
Owner

Why

One dropped connection failed a whole job. The forge's runner log has shown "connection reset by peer" through Cloudflare today, so these happen. The app tried a git clone or fetch, a tool's download and pip install once each. Then it sent /fail, which did two things:

  • It put the PC in the job's failed_agents, so the job was never offered to that PC again. A job aimed at one tester (tester-<login>) then had nobody left to run it.
  • It counted toward the job's error, which comes at the third PC.

What changed

The app (agent/):

  • NetworkRetry.RunAsync tries a network step again after a failure, waiting 5, 20 and 60 s, and says why and which try ("git fetch of main failed: …; trying again in 20 s (try 3 of 4)"). It's used for:
    • the clone, which first clears what a failed clone left;
    • the fetches of main and the PR;
    • Linux's linux_tools.py env --install, Windows' tool downloads and pip install. A tool already fetched and checked is kept, so a new try picks up where the last one failed.
  • When all tries fail, the error is passing (InfraException.Passing). /fail sends "passing": true, and the app's log says the farm will offer the job again.
  • Errors that aren't about the network (out of disk, a missing script, a build that fails) are not retried and don't count as passing.

The farm (coordinator/):

  • A passing fail puts the job back in the queue without adding the PC to failed_agents, and without counting toward error. The same PC may take it again. This happens at most 3 times per job (MAX_PASSING_FAILS, column jobs.passing_fails, migration 0011); after that a passing fail counts like any other.
  • The try's row says "passing, tried again: …", and so does the job's last error. An off-target run is still cancelled, as before.
  • docs/protocol.md describes "passing".

Testing

  • Coordinator tests: 410 passed, 1 skipped. New: test_a_passing_fail_is_tried_again_by_the_same_pc covers three passing fails that requeue for the same PC, the fourth counting, and a fail that isn't passing counting at once.
  • Agent checks: 1691 passed. New retry checks: a step that fails twice and then works returns its answer, with each retry's line saying why and which try; one that always fails ends as a passing failure "(tried 3 times)".
  • Not tested: a real dropped connection during a job.

Deploy: the coordinator needs migration 0011. It only adds a column, and I'll back up the database first.

## Why One dropped connection failed a whole job. The forge's runner log has shown "connection reset by peer" through Cloudflare today, so these happen. The app tried a git clone or fetch, a tool's download and `pip install` once each. Then it sent `/fail`, which did two things: - It put the PC in the job's `failed_agents`, so the job was never offered to that PC again. A job aimed at one tester (`tester-<login>`) then had nobody left to run it. - It counted toward the job's `error`, which comes at the third PC. ## What changed **The app** (`agent/`): - `NetworkRetry.RunAsync` tries a network step again after a failure, waiting 5, 20 and 60 s, and says why and which try ("git fetch of main failed: …; trying again in 20 s (try 3 of 4)"). It's used for: - the clone, which first clears what a failed clone left; - the fetches of `main` and the PR; - Linux's `linux_tools.py env --install`, Windows' tool downloads and `pip install`. A tool already fetched and checked is kept, so a new try picks up where the last one failed. - When all tries fail, the error is *passing* (`InfraException.Passing`). `/fail` sends `"passing": true`, and the app's log says the farm will offer the job again. - Errors that aren't about the network (out of disk, a missing script, a build that fails) are not retried and don't count as passing. **The farm** (`coordinator/`): - A passing fail puts the job back in the queue without adding the PC to `failed_agents`, and without counting toward `error`. The same PC may take it again. This happens at most 3 times per job (`MAX_PASSING_FAILS`, column `jobs.passing_fails`, migration 0011); after that a passing fail counts like any other. - The try's row says "passing, tried again: …", and so does the job's last error. An off-target run is still cancelled, as before. - `docs/protocol.md` describes `"passing"`. ## Testing - Coordinator tests: 410 passed, 1 skipped. New: `test_a_passing_fail_is_tried_again_by_the_same_pc` covers three passing fails that requeue for the same PC, the fourth counting, and a fail that isn't passing counting at once. - Agent checks: 1691 passed. New retry checks: a step that fails twice and then works returns its answer, with each retry's line saying why and which try; one that always fails ends as a passing failure "(tried 3 times)". - **Not tested:** a real dropped connection during a job. **Deploy:** the coordinator needs migration 0011. It only adds a column, and I'll back up the database first.
fix: passing failures (the network) are retried, in the app and by the farm
Some checks failed
CI / Conventional Commit title (pull_request) Successful in 7s
CI / Workflow lint (actionlint) (pull_request) Successful in 7s
CI / Coordinator tests (pull_request) Has been cancelled
CI / Agent build and checks (pull_request) Has been cancelled
CI / Coordinator image (pull_request) Has been cancelled
060fcef764
A job failed on one dropped connection: the app tried a git clone or fetch,
a tool's download and pip once, and a failure sent /fail, which put the PC
in the job's failed_agents (never offered it again; a job aimed at one
tester then had nobody left) and counted toward the job's error.

The app: those network steps are tried again (NetworkRetry: after 5, 20 and
60 s), saying why and which try; a failed clone's leftovers are cleared
first. The last failure is passing, and /fail says so.

The farm: a passing fail puts the job back in the queue without counting
against the agent, which may take it again, at most 3 times per job
(jobs.passing_fails, migration 0011); after that it counts as any other.
The try's row says it was passing and tried again.

Assisted-by: Claude Opus 5.5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Beanstalk!43
No description provided.