fix: make upload timeouts configurable, default to 1 hour (#942) - #944
Merged
alanbchristie merged 1 commit intoMay 28, 2026
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 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. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> EOF )
kaliif
approved these changes
May 28, 2026
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
Mirrors the upload-timeout fix from PR #943 (which targets
staging) ontom2ms-lhs-rhs-unificationso the long-lived feature branch picks it up directly without waiting for a merge fromstaging. Same defaults, same env vars.Closes nothing — issue #942 stays linked via the staging PR.
The m2ms branch had enough divergence (no
gunicorn.conf.py; gunicorn started inline inlaunch-stack.sh; oldersettings.py) that I re-applied the changes by hand rather than cherry-pick.nginx.conf/django_nginx.confare nowenvsubsttemplates. All timeout directives derive fromNGINX_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-coded3000inlaunch-stack.sh. (m2ms invokes gunicorn inline rather than via a config file, so this lives in the launch script — not in agunicorn.conf.py.)Dockerfilepulls ingettext-base(providesenvsubst) and stages the nginx configs as templates under/etc/nginx/templates/.DATA_UPLOAD_MAX_MEMORY_SIZE(default 18 GiB) andFILE_UPLOAD_MAX_MEMORY_SIZE(default 2.5 MiB, Django's own default made explicit) are now env-driven Django settings.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:
Test plan
python -m py_compile fragalysis/settings.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 builddocker compose exec backend cat /etc/nginx/nginx.conf | grep timeoutshows3600son all seven directives; same for/etc/nginx/sites-available/default.confNGINX_TIMEOUT_S=120andSTACK_GUNICORN_TIMEOUT_S=120in compose, restart, confirm rendered values / gunicorn process args 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