Skip to content

Deploy check: survive idle-connection closes and Modal preemptions in the staged calculation step #281

Closed

Description

@anth-volk

Problem

The production deploy (.github/workflows/deploy.yml, job "Modal backend, then Vercel frontend") promotes a Vercel candidate only after the step "Run staged national and state calculations" passes. That step runs frontend/scripts/deployment_smoke.py --check full, which sends one request for the national spm_unit_spm_threshold and California's ca_income_tax through the candidate's /calibration/dashboard/api/microcosm_variable route. The calculation takes about 4 to 6 minutes, and no data flows on the connection until the result arrives.

The deploy of #279's merge (run 42093437237, commit 14bab95) failed at that step on both attempts. #279 changed no backend file.

  • Attempt 1: the connection was closed while idle. The first request was closed about 266 s in, before any response arrived. The check then waited for the backend and retried, and the retry was also closed about 266 s in. Vercel logged HTTP 200 for both calculation requests, and Modal finished them after 347 s and 296 s, so the route and the backend both completed. An earlier deploy (run 40497154118) also lost this connection about 274 s in. This fits a limit on idle connections on the network path between the GitHub-hosted runner and Vercel, such as Azure's default 4-minute idle timeout for outbound connections, but that is not confirmed.
  • Attempt 2: Modal preempted the container. 306 s into the request, Modal logged "Container terminated due to preemption. Your Function will be restarted with the same input." The backend's response was an HTTP 500 without a JSON body, so the route answered HTTP 502 {"detail":"The calculation backend did not return JSON."}. The check never retries an HTTP error, so it failed at once.

Change

  1. Send every request of the deployment check on a connection with TCP keepalive: SO_KEEPALIVE on, with TCP_KEEPIDLE 60 s, TCP_KEEPINTVL 30 s and TCP_KEEPCNT 5 where the platform defines each.
  2. When the full check gets the route's 502 with that detail, handle it like a lost connection: wait until the backend answers a metadata request, then send the full check once more and validate the retried response the same way. A 504 (slow calculation), any other HTTP error and a failed validation still fail at once, and there is still at most one retry.
  3. Check how long the check waits for the backend (BACKEND_FREE_DEADLINE_SECONDS) against a preemption about 300 s in, followed by a new run of up to 800 s, and against the job's 45-minute limit.
  4. Update step 7 of frontend/HOSTED_RUNTIME.md.

Done when

The production deploy's calculation check keeps its connection alive with TCP keepalive, retries once after the route's non-JSON-backend 502, still fails a slow calculation, and #279's merge then deploys to production.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions