Repository navigation
Let API v1 staging's Cloud Run requests run for 900 seconds - #4375
Merged
Merged
Conversation
…imeout Staging's deploy job should set CLOUD_RUN_TIMEOUT to 900 and the deploy script should pass it to gcloud as --timeout; production sets none and keeps cloud_run_env.sh's 300. Fails until the staging job sets it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pin CLOUD_RUN_TIMEOUT: "900" in push.yml's deploy-cloud-run-staging job. deploy_cloud_run_candidate.sh passes it to gcloud run deploy as --timeout. Staging's single instance shares app v3 previews' household calculations between two workers, so a reform calculation took about 600 s there, and at 300 s Cloud Run answered 504 while the worker went on calculating. Production sets no timeout and keeps cloud_run_env.sh's 300. Fixes #4372 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…on goes on The dry-run test now lays the deploy step's env over its job's, so a step-level CLOUD_RUN_TIMEOUT that GitHub Actions would deploy with fails it. The calculation outlives a 504 because Flask handles the request on a2wsgi's thread pool and a closed connection doesn't stop that thread, not because of gunicorn's --timeout 0. The incident account now lives only in the operations document; the workflow comment and the test point to it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…est timeout The guard test compared the check's 320 s wait with cloud_run_env.sh's default, not with the timeout of the candidate the check runs against. It now reads the CLOUD_RUN_TIMEOUT that deploy-cloud-run-staging's deploy step gets, through a shared deploy_step_environment helper, and fails: 320 s is not longer than staging's 900 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The check runs against the staging candidate, whose requests may now run for 900 s. Waiting 920 s keeps it longer than that timeout, so the check still gets the candidate's own answer, a 504 included, as its guard test requires. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y the parity check outwaits it deploy_step_request_timeout_setting returns the CLOUD_RUN_TIMEOUT a deploy step gets as script env, so the three timeout tests read it the same way; deploy_step_environment says which job lacks one deploy step and returns YAML's values as parsed. The parity wait's comments give its reason, the candidate's own answer, and the rewrapped paragraphs read as whole lines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The parity check now waits up to 920 s for one API v1 answer, and the job's two pytest runs take about 20 minutes, so 30 minutes would end the job before an answer at the staging candidate's 900 s limit is reported. Fails until the job's timeout-minutes is 45. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
So an API v1 answer at the staging candidate's 900 s request timeout, which the parity check now waits for, is reported before the job's limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The live job test now reads timeout-minutes from the parsed workflow and checks it leaves room for the two pytest runs and one API v1 answer that takes the full V1_CALCULATION_TIMEOUT_SECONDS, so raising the wait alone fails it. The comments say the runs take about 20 minutes together and that two full-length answers in a row on one worker don't fit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4375 +/- ##
==========================================
- Coverage 94.04% 94.03% -0.02%
==========================================
Files 449 449
Lines 25349 25349
Branches 3905 3930 +25
==========================================
- Hits 23840 23837 -3
- Misses 860 865 +5
+ Partials 649 647 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch was previously deployed
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.
Fixes #4372
Summary
policyengine-api-staging) lets a request run for up to 900 seconds instead of 300.push.yml'sdeploy-cloud-run-stagingjob pinsCLOUD_RUN_TIMEOUT: "900"beside itsCLOUD_RUN_MAX_INSTANCES: "1", anddeploy_cloud_run_candidate.shalready passesCLOUD_RUN_TIMEOUTtogcloud run deploy --timeout.WSGIMiddleware), and a closed connection doesn't stop that thread. The retries added calculations until gunicorn reported a worker killed by SIGKILL, most likely for running out of memory.deploy-cloud-run-candidatejob sets no timeout and keepscloud_run_env.sh's 300 seconds. Staging's maximum instances stay at 1.test_live_v2_household_parity), which runs against the staging candidate before promotion, now waits 920 seconds instead of 320 for API v1's/calculateor/calculate-fullanswer. It stays longer than the candidate's request timeout, so the check still gets the candidate's own answer, a 504 included. Its guard test now reads the staging deploy step'sCLOUD_RUN_TIMEOUTinstead ofcloud_run_env.sh's default. Normal answers take about 224 seconds.parallel-live-simulation-tests-staging-cloud-run) getstimeout-minutes: 45instead of 30. It took 18 to 20 minutes in the last three release runs, so with 30 minutes a single API v1 answer near 900 seconds would end the job before the test reported it. Normal runs are unchanged; only a slow run uses the extra runner time.docs/migration/cloud-run-operations.mdgains a "Request timeout" paragraph under "Runtime shape and scaling"; the parity wait is updated inrun_live_staging_tests.shanddocs/migration/stage-11-v2-households.md.app/src/api/householdCalculation.tsinpolicyengine-app-v2) still applies, so this change alone doesn't make the Household tab work on staging. A household calculation still has no deadline of its own.Environment variables
CLOUD_RUN_TIMEOUTdeploy-cloud-run-stagingjob's ownenv:block inpush.yml, a literal"900"(no GitHub variable or secret)env:reaches every step of the job; the "Deploy tagged Cloud Run staging candidate" step's ownenv:doesn't set it. That step runsdeploy_cloud_run_candidate.sh, which sourcescloud_run_env.sh(CLOUD_RUN_TIMEOUT="${CLOUD_RUN_TIMEOUT:-300}", exported) and passes--timeout "${CLOUD_RUN_TIMEOUT}"togcloud run deploy.validate_cloud_run_deploy_env.shdoesn't read it. No reusable workflow orsecrets:passing is involved.env:sets it, and no other job or step does (the new test checks every job and step). The same script therefore deployspolicyengine-apiwith the default 300.promote-cloud-run-stagingrunsset_cloud_run_revision.sh, which only moves traffic (gcloud run services update-traffic). The timeout belongs to the revision the deploy step creates.gcloudchecks show staging is reached at itsrun.appURL, with no domain mapping and no load-balancer backend service (the only one,bs-cloud-run, is production's). So Cloud Run's request timeout is staging's only server-side limit.CLOUD_RUN_MAX_INSTANCESis unchanged.Unverified:
VITE_API_URLpoints at staging'srun.appURL. This comes from the 2026-11-30 investigation; it wasn't read from Vercel.timeoutSeconds300. The new value takes effect when the next release deploys staging after this merges.Testing
Red-green:
d1f967b13added the workflow tests and they failed, then6f4eb88b4made them pass.320535be5changed the parity guard test and it failed (320.0 > 900.0), then0dec24d54made it pass.19ee0b2d5changed the live job's limit assertion to 45 minutes and it failed, thenc19c3b8b1made it pass.tests/unit/test_cloud_run_push_workflow.py::test_only_the_staging_deploy_raises_the_cloud_run_request_timeout: no workflow-levelenv:setsCLOUD_RUN_TIMEOUT, the only job whose own or stepenv:sets it isdeploy-cloud-run-staging, and the value is"900".tests/unit/test_cloud_run_push_workflow.py::test_each_deploy_job_passes_its_request_timeout_to_gcloud: a dry run ofdeploy_cloud_run_candidate.shwith each deploy step's timeout setting (workflow, job and stepenv:combined) passes--timeout 900for staging and--timeout 300for production. AddingCLOUD_RUN_TIMEOUT: "300"to the staging deploy step by hand makes it fail.tests/unit/v2/test_live_household_parity_requests.py::test_the_check_waits_longer_than_the_candidate_lets_a_request_run: the parity check's wait is longer than the staging candidate's request timeout.tests/unit/test_cloud_run_push_workflow.py::test_push_workflow_tests_the_staging_candidate_before_promoting_it: the live staging job hastimeout-minutes: 45.make quality,lint-imports,python -m scripts.rules validate,python scripts/run_quality_guards.py,ruff check,ruff format --check,check_changelog_fragment.shandactionlint .github/workflows/push.ymlpass.🤖 Generated with Claude Code