Skip to content

ci: abort stalled git fetches so checkout retries instead of hanging - #22890

Merged
Git-on-my-level merged 1 commit into
mainfrom
ci/checkout-stall-bound
Oct 20, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
ci/checkout-stall-bound

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

David named this workflow change on 2026-10-20 (two-lane lead session).

Problem

On 2026-10-20, Backend Hermetic E2E run 39435458398 (push to main) spent 498 s in the Hermetic Backend E2E job's "Checkout code" step, against a ~26 s p50. The job hit its 10-minute cap with only about 92 s left for tests.

The checkout was already minimal: fetch-depth: 1, lfs: false, submodules: false. The log shows a network stall, not a large transfer:

14:14:15  git fetch --depth=1 origin +df22320e…:refs/remotes/origin/main
14:21:54  error: RPC failed; curl 56 Recv failure: Connection reset by peer
14:21:54  Waiting 13 seconds before trying again
14:22:07  git fetch --depth=1 …   (retry)
14:22:28  * [new ref] df22320e… -> origin/main      (21 s)

git has no stall timeout by default, so a fetch that stops receiving data waits for the TCP reset (7-10 minutes) before actions/checkout's built-in retry can run. I found the same stall in other jobs in the last 300 repo runs (fetch line, then nothing until reset or cancel):

Job (workflow) Checkout Outcome
Hermetic Backend E2E (backend-hermetic-e2e) 498 s job timeout
Detect Hermetic Backend Scope (backend-hermetic-e2e) 599 s job timeout (10 min)
Public Developer API contract (openapi-contract) 751 s cancelled
Dart Analyze & Tests / Android Emulator Acceptance (mobile-app-checks) 255 s+ cancelled mid-fetch
Detect Desktop Swift Changes (desktop-swift-ci) 153 s success
Static Contracts (backend-checks) 141 s success
Formatting (repo-checks) 123 s success

Fix

  • Workflow-level GIT_HTTP_LOW_SPEED_LIMIT=1000 and GIT_HTTP_LOW_SPEED_TIME=60 in the six workflows above. git aborts any HTTP transfer that stays under 1 KB/s for 60 s, so actions/checkout moves on to its retry (3 attempts) instead of hanging. A healthy depth-1 fetch takes ~20 s while data streams, so this does not trip on normal runs. The variables also bound git calls in later script steps.
  • backend-hermetic-e2e: timeout-minutes: 5 on every checkout step as a backstop: three stalled attempts plus backoff is about 3.5 minutes.
  • Hermetic Backend E2E job cap goes from 10 to 15 minutes, which is the 10-minute setup-and-test budget plus the 5-minute checkout backstop. A slow checkout that recovers no longer uses up the test budget.

I left fetch-depth, LFS, submodules and sparse-checkout unchanged. They were already minimal (the scope job needs full history for its base diff), and the stall comes from the network, not from transfer size.

Checkout durations: before and after

Before: the jobs API step timings for the last 60 Backend Hermetic E2E runs, plus every failed or cancelled run in the last 400 (and 300 repo-wide runs):

Sample n p50 p95 max >120 s
Hermetic Backend E2E job 30 26 s 33 s 498 s 1
All Backend Hermetic E2E workflow jobs 156 31 s 48 s 599 s 2
Repo-wide, last 300 runs 279 36 s 78 s 751 s 5

After (this PR's CI, head f5d64f9):

These are this PR's own runs: 10 runs and 30 jobs with a checkout step.

Sample n p50 p95 max >120 s
Hermetic Backend E2E job 1 25 s 25 s 25 s 0
Backend Hermetic E2E workflow jobs (scope 34 s, E2E 25 s, listen 26 s, sync 39 s) 4 30 s 39 s 39 s 0
All PR jobs with checkout 30 36 s 71 s 127 s 1

The 127 s outlier is iOS Compile Check, a macOS runner doing a full-history fetch of all branches with no blob filter. Its log shows 116 s of continuous transfer and no retry, so the 60 s / 1 KB/s stall abort did not fire on a legitimate slow fetch.

The stall is intermittent: about 5 in 279 jobs on the repo-wide baseline. A 30-job sample can't prove the bounded retry works on a real stall. What it shows is that a healthy checkout is unchanged and that slow but live transfers aren't aborted. Proof of the stall fix will come from a post-merge run that logs Waiting N seconds before trying again about 60 s after the fetch starts, instead of 7-10 minutes later.

CI notes: Sync Cloud Tasks Stack Gauntlet failed once with StackFailure('a segment was computed more often than it was leased across replicas'). The same class of failure appears on main (for example, run 39442681757: computed or completed more than once across replicas), and the gauntlet failed in 12 of its 22 completed runs in the baseline sample. It is unrelated to this change. One rerun --failed passed, and every check is green.

Verification

  • actionlint on all six workflows: no new findings. The two shellcheck notes in desktop-swift-ci.yml are already on main.
  • backend/tests/unit/test_workflow_contracts.py, test_listen_pusher_stack_ci_wiring.py, test_sync_cloud_tasks_stack_ci_wiring.py, .github/scripts/test_desktop_swift_ci_contract.py, test_check_workflow_apt_network_bounds.py: 172 passed. check_workflow_apt_network_bounds.py OK.

Follow-up, not in this PR: the other ~66 workflows that use actions/checkout could get the same env block if stalls show up there.

🤖 Generated with Claude Code

Hosted-runner fetches from github.com intermittently stop receiving data
for 7-10 minutes before the connection resets. Backend Hermetic E2E run
39435458398 spent 498 s in a depth-1 Checkout code (stall 14:14:15 ->
14:21:54, retry succeeded in 21 s) and hit its 10-minute job cap.

- Workflow-level GIT_HTTP_LOW_SPEED_LIMIT=1000 / GIT_HTTP_LOW_SPEED_TIME=60
  in the six workflows where stalled checkouts were observed in the last
  300 runs, so git aborts a stalled transfer and actions/checkout's
  built-in retry runs.
- backend-hermetic-e2e: 5-minute timeout on every checkout step; the
  Hermetic Backend E2E job cap goes 10 -> 15 so checkout no longer eats
  the test budget.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T16:40:24.378832Z f5d64f9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Git-on-my-level
Git-on-my-level merged commit 43577cb into main Oct 20, 2026
69 of 71 checks passed
@Git-on-my-level
Git-on-my-level deleted the ci/checkout-stall-bound branch October 20, 2026 17:53
Git-on-my-level added a commit that referenced this pull request Oct 20, 2026
…ce, batch verify, local CPU cap, pusher probe) (#22936)

David named this workflow change on 2026-10-20 (two-lane lead session):
CI/release reliability

## Summary
This PR fixes five CI and release reliability problems from 2026-10-20.
It edits existing workflows and scripts only; it adds no new workflow
files.

### 1. Checkout stall bound everywhere
- **Before:** #22890 set `GIT_HTTP_LOW_SPEED_LIMIT=1000` /
`GIT_HTTP_LOW_SPEED_TIME=60` on 6 workflows. The other 66 that use
`actions/checkout` could still hang 7–10 minutes on a stalled fetch,
until the TCP reset.
- **After:**
- All 72 checkout workflows set both variables in their workflow-level
`env`. The edit was mechanical: the keys go at the top of an existing
`env:` block, or a new block goes before `jobs:`.
- A new guard,
`.github/scripts/check_workflow_checkout_stall_bounds.py`, fails when a
workflow checks out without them. It is registered in the manifest as
`workflow-checkout-stall-bounds` (local + ci lanes) and modeled on
`workflow-apt-network-bounds`.
- A workflow that calls a local composite action which itself runs
`actions/checkout` is held to the same rule (`deploy-backend-stack`,
`firestore-readiness`). Otherwise moving a checkout into an action would
hide the missing bound.
- **Verified:** 9 guard self-tests, including the real tree (80 workflow
files OK). `actionlint` on all 66 edited workflows reports no new
non-shellcheck findings. The apt guard and the manifest tests still
pass.

### 2. Codemagic source-pin race
- **Before:** `dispatch_mobile_internal_builds.py` dispatches a *branch*
with `OMI_RELEASE_SOURCE_SHA`. Codemagic's "Verify dispatcher source
pin" failed whenever main moved during the roughly one minute before
clone. Both the iOS and Android internal builds died that way on 10-20.
- **After:** both internal workflows run
`app/scripts/checkout_release_source_pin.sh`.
  - If HEAD equals the pin, the build continues unchanged.
- If main moved and the cloned tip still contains the pin (`merge-base
--is-ancestor`, fetching or unshallowing if needed), it checks out the
pin detached and re-verifies HEAD. The build then uses exactly the
evaluated commit, and `build_provenance_dart_defines.sh`'s HEAD==pin
check still holds.
- Everything else fails closed: an invalid pin, a pin the tip does not
contain, or a failed fetch or checkout.
- The body runs as a single parsed function, so checking out a different
commit cannot rewrite the script while it runs.
- **Why not a tag:** dispatching a `ci/mobile-internal/<sha>` tag needs
`contents: write` in the dispatcher, adds a tag to the public repo per
build, and could fire Codemagic's `tag_push` workflows.
- **Known limit:** Codemagic still reads `codemagic.yaml` from the tip.
Only the step definitions are newer; the source being built is the pin.
- **Verified:** 6 new tests run the script against temporary git repos:
matching, moved tip, pin off the tip's history, invalid or unknown pin,
unpinned, and both workflows wired. **Not yet verified on a live
Codemagic build**; the next mobile internal build is the check.

### 3. Batch worker deploy false failure
- **Cause:** run 39456573983, job 118744919919. Verify rollout started
at 16:32:38Z and the job closed at 17:19:30Z. The only annotation is
*"The hosted runner lost communication with the server"*. The log is
`BlobNotFound`, and the `always()` summary and notify steps stayed
pending. So the runner died; it was not a hung `kubectl` or a timeout.
`rollout status --timeout=1800s` must have returned by 17:02, and no job
timeout was set (default 360 min).
- **Names are correct:** the Deployment is `{{ .Release.Name }}` =
`prod-omi-batch-pipeline-worker`, matching `deploy/$TARGET_RELEASE`.
- **Real gaps found:**
  - Nothing except `rollout status` was bounded.
- The 1800 s wait (and the chart's `progressDeadlineSeconds: 1800`) is
shorter than Recreate's 1500 s old-pod drain plus GPU startup, so a
healthy rollout could report failure.
  - The check never confirmed the built digest.
- **After:**
- Job `timeout-minutes: 75` (healthy runs take ~14 min) and step
`timeout-minutes: 45`.
- `rollout status` waits 2400 s for batch-pipeline-worker, and the
chart's `progressDeadlineSeconds` is raised to 2400 to match.
- After rollout, the step asserts the Deployment template serves
`@$EXPECTED_DIGEST`.
- `deploy_status_report.py` is capped with `timeout 120`, and its
`kubectl get` calls carry `--request-timeout=30s`.
- A hang now ends as a failure, and the summary and Telegram steps still
run. A lost runner still ends with no conclusion; the in-place comment
says to re-run the job. Splitting verify into its own job would
re-trigger the `prod` environment gate, so I left it out.
- **Verified:** the updated and new tests in
`test_batch_pipeline_chart.py` run the real step script with a stub
kubectl. They cover the 2400 s/600 s budgets, digest match passes,
digest mismatch fails, and the timeouts are present. 94 tests passed
across the chart, `deploy_status_report` and workflow-contract files.

### 4. Local pre-push CPU cap
- **Before:** `backend/test.sh` defaulted
`BACKEND_FAST_UNIT_FAIL_SECONDS` to 0.30 s, against CI's 1.0 s. On 10-20
it failed lane 1's sync push twice on tests that pass alone and pass in
CI.
- **After:** the local default is 1.0 s, the same as
`backend/scripts/run-unit-ci.sh` (unchanged). The 0.1 s warn target
still reports anything over it. The README and allowlist header are
updated.
- **Verified:** `test_fast_unit_duration_guard.py` and
`test_backend_unit_ci_runner.py` pass. CI's limit is untouched.

### 5. Pusher dev live probe `listen_closed_early`
- **Root cause:** there were six failures, not three, all in
`gcp_backend_pusher_auto_deploy.yml` on 10-19/20, including 5098bbc,
ff9e323 and fbb197a. Each one came 15–17 s after a `helm upgrade
dev-omi-backend-listen`, started by `gcp_backend_auto_dev.yml` or
`gcp_backend_listen_helm.yml`, landed mid-probe.
- Those workflows hold the `deploy-backend-stack-development` lock, not
the pusher lock.
- Dev listen runs one replica with `preStop: sleep 15`, so the pod the
port-forward is pinned to terminates mid-probe.
  - The passing rerun had no listen rollout during it.

| Pusher run (SHA) | Probe start | Listen upgrade (run) | Probe FAIL |
|---|---|---|---|
| 39328054517 (4981b47) | 21:37:55 | 21:40:03 (39323936732) | 21:40:19
|
| 39343445910 (bc5482c) | 23:51:27 | 23:53:18 (39340357028) | 23:53:35
|
| 39408703781 (ff9e323) | 10:38:30 | 10:41:30 (39405193597) | 10:41:46
|
| 39412650530 (5098bbc) | 11:32:24 | 11:34:24 (39409319664) | 11:34:40
|
| 39464841497 a1 (fbb197a) | 17:28:10 | 17:28:33 (39464841503) |
17:29:12 |
| 39472466605 (3383bc6) | 18:18:06 | 18:20:30 (39466434123) | 18:20:45
|

- **Fix:** a bounded retry with the reason logged. Sharing the
backend-stack lock would make the probe and queued backend deploys
cancel each other, because GitHub keeps only one pending run per group.
- The probe receipt and status line now carry `listen_close_code`. Only
the code is recorded, never the reason text.
- The step waits for any in-flight listen rollout, records the listen
Deployment's `metadata.generation`, and runs the attempt.
- It retries **once**, and only when the stage is `listen_closed_early`
and the generation changed during the attempt. It then emits a
`::warning` with the stage, close code and generation change, and keeps
the first receipt as `pusher-dev-semantic-probe.attempt1.json`
(uploaded).
- Setup failures, any other stage, an unchanged generation, or an
unreadable generation are final.
- **Verified:** 5 new tests run the real step script with stubbed
kubectl, python3 and curl:
  - retry then pass;
  - no retry when the generation is unchanged;
  - no retry for another stage;
  - at most one retry;
  - the attempt receipt is uploaded.

The probe tests assert close code 1006 in the receipt and the status
line. All 26 tests in `test_pusher_deployment_control_workflow.py` pass,
including the bash-5 parse check.

### 6. Main-red Windows CLI job (found while merging)
- **Before:** `python-cli-ci` "Windows ACL / Python 3.12" has been red
on main since 2026-10-20 (run 39442884972). It fails
`test_conversation_from_segments_rejects_directory` and
`..._file_parent_is_not_a_directory`. The job runs on this PR only
because `python-cli-ci.yml` gained the stall env.
  - #22271 opened the segments file directly and relied on POSIX errors.
- On Windows, opening a directory raises `PermissionError` rather than
`IsADirectoryError`, and a path under a regular file raises
`FileNotFoundError` rather than `ENOTDIR`.
- **After:** `from_segments` recognizes both cases. The
`is_dir`/`is_file` probes are wrapped so they cannot raise a second
error.
- **Verified:** 2 new tests simulate the Windows exceptions on every OS.
The full CLI suite passes locally on macOS (922 passed, 1 skipped). The
real Windows job is verified by this PR's CI.

## Review (Grok, via agentctl)
The first pass returned REQUEST_CHANGES with three findings, all fixed
in 96a3564:
1. **Blocker:** the pinned Codemagic build would still fail later, in
`build_provenance_dart_defines.sh`, because HEAD != `CM_COMMIT` (the
cloned tip).
- The pin script now writes `OMI_RELEASE_PIN_CLONED_TIP` to `$CM_ENV`,
and fails closed if `CM_ENV` is unset inside Codemagic.
- Provenance accepts the mismatch only when HEAD is the pin, the
recorded tip equals `CM_COMMIT`, and the pin is an ancestor of it.
- Tests cover the accept case and three reject cases in
`build_provenance_dart_defines_test.sh`, plus the `CM_ENV` record in the
dispatcher tests.
2. **Major:** the pusher retry could fire when the after-read of the
generation failed (`unknown` != numeric). Both reads must now be
integers and must differ; two test cases were added.
3. **Minor:** the guard missed staged action paths
(`./.github/firestore-workflow/.github/actions/firestore-readiness`). It
now matches by suffix; a test was added.

## Lane / contract
Lane `ci-rel` (P4), CI/release reliability; owner sign-offs for edits to
other lanes' files: none

## Product invariants affected
- INV-DATA-1: path match only. The workflow-level `GIT_HTTP_LOW_SPEED_*`
env lines were added to production-family deploy workflows (and the
batch-worker Verify rollout bounds). No routing or data-plane behavior
changes.
- INV-AUTH-1: path match only. The checkout stall env was added to a
desktop workflow; no auth/session code is touched.
- INV-BETA-1: path match only. The checkout stall env was added to a
desktop release workflow; no Beta promotion logic changes.
- INV-MEM-4: path match only. The checkout stall env was added to
memory-maintenance job workflows; no memory pipeline code is touched.

## Verification
- **Layer measured:** unit and contract tests plus static lint only. No
workflow ran live; no deploy.
- **Targeted tests:**
- `backend/test.sh` with `test_batch_pipeline_chart`,
`test_deploy_status_report` and `test_workflow_contracts`: 94 passed.
  - `test_pusher_deployment_control_workflow`: 26 passed.
- `test_pusher_semantic_probe`, `test_fast_unit_duration_guard` and
`test_backend_unit_ci_runner`: passed.
- `.github/scripts`: checkout-stall guard (9), apt guard,
`test_run_checks` (one environment-only failure,
`test_new_marker_requires_tracking_issue`, unrelated), and the new
dispatcher pin tests (15 incl. existing).
- **Not run locally:**
`TestPendingCommits.test_a_non_ancestor_baseline_counts_as_pending`,
which already hangs in a local partial clone. It is unchanged by this
PR; CI uses a full clone.

## Rollback
Revert this PR. Each item is independent, and no data or runtime state
changes. The chart's `progressDeadlineSeconds` takes effect only on the
next batch-worker deploy.

Failure-Class: none

🤖 Generated with [Claude Code](https://claude.com/claude-code)
adrbn pushed a commit to adrbn/omi that referenced this pull request Oct 21, 2026
…ce, batch verify, local CPU cap, pusher probe)

David named this workflow change on 2026-10-20 (two-lane lead session): CI/release reliability

- Checkout stall bound everywhere: GIT_HTTP_LOW_SPEED_LIMIT/TIME at workflow
  level in the 66 workflows BasedHardware#22890 did not cover, plus a manifest-registered
  guard (workflow-checkout-stall-bounds) that fails when a workflow checks out,
  directly or through a local composite action, without them.
- Codemagic source-pin race: the internal iOS/Android pin step now runs
  app/scripts/checkout_release_source_pin.sh, which checks out the evaluated
  SHA when main moved past it between dispatch and clone, and fails closed on
  an invalid pin, a pin the tip does not contain, or a failed fetch/checkout.
- Batch worker deploy: Verify rollout is bounded at every layer (job 75 min,
  step 45 min, kubectl request timeouts, status report capped), its wait covers
  Recreate's 1500 s drain plus GPU startup (2400 s, chart progress deadline to
  match), and it asserts the deployment serves the built digest. The 10-20 run
  lost its runner; that still needs a job re-run, now documented in place.
- Local pre-push CPU cap: test.sh's default fail limit 0.30 s -> 1.0 s, same as
  CI's runner (unchanged). Warn target stays 0.1 s.
- Pusher dev probe: all six listen_closed_early failures on 10-19/20 landed
  15-17 s after a dev listen helm upgrade under the other deploy lock. The
  probe now records the WebSocket close code, and the step retries once, only
  for listen_closed_early and only when the listen Deployment's generation
  changed during the attempt; the first receipt is kept as attempt1.

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant