fix: make upload timeouts configurable, default to 1 hour (#942) - #943
Open
alanbchristie wants to merge 3 commits into
Open
fix: make upload timeouts configurable, default to 1 hour (#942)#943alanbchristie wants to merge 3 commits into
alanbchristie wants to merge 3 commits into
Conversation
Large file uploads (e.g. 6 GiB) were producing 504 Gateway Timeout because every hop in the request path had its own timeout and the in-container nginx capped at 1000s. - nginx.conf / django_nginx.conf are now envsubst templates; all timeout directives derive from STACK_NGINX_TIMEOUT_S (default 3600s) rendered by launch-stack.sh before nginx -tq runs. nginx's own $vars pass through untouched (envsubst is scoped to the one variable). - gunicorn worker timeout is now driven by STACK_GUNICORN_TIMEOUT_S (default 3600s), replacing the hard-coded 3000s. - Dockerfile pulls in gettext-base for envsubst and stages the nginx configs as templates under /etc/nginx/templates/. - DATA_UPLOAD_MAX_MEMORY_SIZE and FILE_UPLOAD_MAX_MEMORY_SIZE are now env-driven Django settings so request-body and in-memory upload thresholds are explicit (defaults 10 GiB and 2.5 MiB). The Kubernetes NGINX ingress controller is configured in fragalysis-stack-kubernetes; it must be raised to >=3600s in lockstep or this change alone won't lift the 504. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
9 tasks
alanbchristie
added a commit
that referenced
this pull request
May 28, 2026
Large file uploads (e.g. 6 GiB) were producing 504 Gateway Timeout because every hop in the request path had its own timeout, and the in-container nginx capped at 1000s. - nginx.conf / django_nginx.conf are now envsubst templates; all timeout directives derive from NGINX_TIMEOUT_S (default 3600s) rendered by launch-stack.sh before nginx -tq runs. nginx's own $vars pass through untouched (envsubst is scoped to the one variable). - Gunicorn --timeout is now driven by STACK_GUNICORN_TIMEOUT_S (default 3600s), replacing the hard-coded 3000s in launch-stack.sh. - Dockerfile pulls in gettext-base for envsubst and stages the nginx configs as templates under /etc/nginx/templates/. - DATA_UPLOAD_MAX_MEMORY_SIZE (default 18 GiB) and FILE_UPLOAD_MAX_MEMORY_SIZE (default 2.5 MiB, Django's own are now env-driven Django settings so request-body and in-memory upload thresholds are explicit and tunable. The Kubernetes NGINX ingress controller is configured in fragalysis-stack-kubernetes; it must be raised to >=3600s in lockstep or this change alone won't lift the 504. Mirrors the change applied to staging via PR #943. EOF ) Co-authored-by: a.b.christie <alan.christie@matildapeak.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
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.
Summary
Closes #942 (in this repo). Large file uploads (e.g. 6 GiB) were producing 504 Gateway Timeout because every hop in the request path had its own timeout, and the in-container nginx capped at 1000s (~16.7 min).
nginx.conf/django_nginx.confare nowenvsubsttemplates. All timeout directives derive fromSTACK_NGINX_TIMEOUT_S(default 3600s) rendered bylaunch-stack.shbeforenginx -tqruns.envsubstis scoped to that single variable so nginx's own$vars(e.g.$http_host,$;regex anchors) pass through untouched.timeoutis now driven bySTACK_GUNICORN_TIMEOUT_S(default 3600s), replacing the hard-coded3000s.Dockerfilepulls ingettext-base(providesenvsubst) and stages the nginx configs as templates under/etc/nginx/templates/.DATA_UPLOAD_MAX_MEMORY_SIZE(default 10 GiB) andFILE_UPLOAD_MAX_MEMORY_SIZE(default 2.5 MiB, Django's own default made explicit) are now env-driven Django settings so request-body and in-memory upload thresholds are visible and tunable.fragalysis-stack-kubernetesThe Kubernetes NGINX ingress controller (v1.12.0) is configured in fragalysis-stack-kubernetes, not here. Its defaults (60s) will still produce 504s regardless of this PR. The ingress (or per-route annotations on the upload endpoint) must be raised in lockstep:
The two new Django env vars (
DATA_UPLOAD_MAX_MEMORY_SIZE,FILE_UPLOAD_MAX_MEMORY_SIZE) and the two new stack env vars (STACK_NGINX_TIMEOUT_S,STACK_GUNICORN_TIMEOUT_S) should be surfaced asstack_*Ansible variables in the playbook repo if they need to be tunable per-deployment.Test plan
python -m py_compile fragalysis/settings.py gunicorn.conf.pybash -n launch-stack.sh$varsand regex anchors preserveddocker compose up -d --buildsucceeds andnginx -tq(run insidelaunch-stack.sh) passes — please verify in a real container build; skipped here as it re-runs the full apt/texlive layer (~10+ min)docker compose exec backend cat /etc/nginx/nginx.conf | grep timeoutshows3600son all seven directives; same for/etc/nginx/sites-available/default.confSTACK_NGINX_TIMEOUT_S=120in compose, restart, confirm rendered values changedocker compose exec backend python manage.py shell -c "from django.conf import settings; print(settings.DATA_UPLOAD_MAX_MEMORY_SIZE, settings.FILE_UPLOAD_MAX_MEMORY_SIZE)"returns the expected ints🤖 Generated with Claude Code