Skip to content

feat(agent): friendly 504 page for paused/timing-out upstreams - #438

Open
runleveldev wants to merge 2 commits into
mainfrom
435
Open

feat(agent): friendly 504 page for paused/timing-out upstreams#438
runleveldev wants to merge 2 commits into
mainfrom
435

Conversation

@runleveldev

Copy link
Copy Markdown
Collaborator

Summary

Adds a friendly 504 error page for frozen/paused or OOMing-but-alive containers.

When a container is frozen (cgroup.freeze) or OOMing but still alive, it keeps its TCP socket open but never responds. NGINX then hits proxy_read_timeout and returns a bare 504 Gateway Timeout — distinct from a stopped/crashed container, which refuses the connection and yields 502. Previously only 502.html existed, so a paused/slow upstream produced an unstyled 504.

Part of #431 (memory-exhaustion thrash). Closes #435.

Changes

  • error-pages/504.html — new page ("Service Paused") explaining the app is paused/under heavy load and should return shortly. Styled to match the existing error pages (dark gradient, grid overlay, glass card, JS-injected hostname); uses an amber/gold gradient to read distinctly from 502 (blue/purple) and 503 (orange/red).
  • agent/templates/nginx.conf.ejs — wires error_page 504 @504 following the established @502 pattern in every server block that already handles 502 (default HTTPS server, per-service blocks, bare-domain docs server), and adds location /504.html { } to the internal error-pages socket server.
  • error-pages/502.html — copy revised to connection-refused semantics ("the upstream refused the connection… likely stopped or has crashed") so 502 vs 504 read sensibly for the memory-thrash case.

No packaging changes needed: agent/Makefile already globs error-pages/* into /opt/opensource-server/error-pages/.

Acceptance criteria

  • A frozen or timing-out upstream renders the friendly 504 page, not a bare gateway error.
  • 502 still renders for connection-refused/stopped containers.
  • Pages are consistent with existing error-pages/ styling.

Verification

Rendered nginx.conf.ejs via EJS across service permutations (no services, plain HTTP, auth+server, auth-no-server, external domains) — all render successfully with the correct number of error_page 504/location @504 blocks and the socket-server location /504.html. nginx -t was not run here (nginx isn't installed in this environment); the agent already runs a config test with rollback on apply, and the 504 wiring mirrors the proven 502 blocks verbatim.

…eams

A frozen (cgroup.freeze) or OOMing-but-alive container keeps its TCP
socket open but never responds, so NGINX hits proxy_read_timeout and
returns a bare 504 Gateway Timeout. Only a 502 page existed.

- Add error-pages/504.html (paused/under-load messaging), styled to
  match the existing pages.
- Wire it via error_page 504 in the agent nginx template alongside the
  existing 502 handling (default server, per-service, and bare-domain
  blocks) plus the internal error-pages socket server.
- Clarify 502 copy as connection-refused (stopped/crashed) so 502 vs
  504 read distinctly for the memory-thrash case.

Part of #431. Closes #435
Copilot AI review requested due to automatic review settings July 31, 2026 19:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a dedicated friendly 504 Gateway Timeout error page and wires it into the agent-generated NGINX config so paused/frozen or timing-out upstream containers render a styled, explanatory page (consistent with existing 502/503 handling and styling).

Changes:

  • Introduces error-pages/504.html (“Service Paused”) styled to match existing error pages.
  • Updates agent/templates/nginx.conf.ejs to route 504s through the internal error-pages socket server (mirroring the existing @502 pattern).
  • Refines error-pages/502.html copy to better align with “connection refused / stopped” semantics.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
error-pages/504.html New friendly 504 page with consistent styling and explanatory troubleshooting text.
error-pages/502.html Updates 502 message copy to distinguish it from 504 timeout scenarios.
agent/templates/nginx.conf.ejs Adds error_page 504 @504 handling and serves /504.html via the internal error page server.

Comment thread error-pages/504.html Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

Add friendly 504 error page for paused/OOMing (frozen) containers

2 participants