Skip to content

chore: switch agent gone response from 502 to 404 (backport #23090)#23635

Merged
f0ssel merged 1 commit intorelease/2.31from
rowan/fix/workspace_agent_502_2.31
Mar 25, 2026
Merged

chore: switch agent gone response from 502 to 404 (backport #23090)#23635
f0ssel merged 1 commit intorelease/2.31from
rowan/fix/workspace_agent_502_2.31

Conversation

@rowansmithau
Copy link
Contributor

Backport of #23090 to release/2.31.

When a user creates a workspace, opens the web terminal, then the workspace stops but the web terminal remains open, the web terminal will retry the connection. Coder would issue a HTTP 502 Bad Gateway response when this occurred because coderd could not connect to the workspace agent, however this is problematic as any load balancer sitting in front of Coder sees a 502 and thinks Coder is unhealthy.

This PR changes the response to a HTTP 404 after internal discussion.

Cherry-picked from merge commit c33812a.

When a user creates a workspace, opens the web terminal, then the
workspace stops but the web terminal remains open the web terminal will
retry the connection. Coder will issue a HTTP 502 Bad Gateway response
when this occurs because coderd cannot connect to the workspace agent,
however this is problematic as any load balancer sitting in front of
Coder sees a 502 and thinks Coder is unhealthy.

The main change is in
https://github.com/coder/coder/pull/23090/changes#diff-bbe3b56ed3532289481a0e977867cd15048b7ca718ce676aae3f3332378eebc2R97,
however the main test and downstream tests are also updated.

This PR changes the response to a [HTTP
404](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/404)
after internal discussion.

<img width="1832" height="1511" alt="image"
src="https://github.com/user-attachments/assets/0baff80d-bb98-4644-89cd-e80c87947098"
/>

Created with the help of Mux, reviewed and tested by a human
@github-actions github-actions bot added the community Pull Requests and issues created by the community. label Mar 25, 2026
@rowansmithau rowansmithau added cherry-pick/v2.29 Needs to be cherry-picked to the 2.29 release branch and removed community Pull Requests and issues created by the community. labels Mar 25, 2026
@rowansmithau rowansmithau requested a review from f0ssel March 25, 2026 19:57
@rowansmithau rowansmithau added cherry-pick/v2.31 Needs to be cherry-picked to the 2.31 release branch and removed cherry-pick/v2.29 Needs to be cherry-picked to the 2.29 release branch labels Mar 25, 2026
@f0ssel f0ssel merged commit f765029 into release/2.31 Mar 25, 2026
69 of 71 checks passed
@f0ssel f0ssel deleted the rowan/fix/workspace_agent_502_2.31 branch March 25, 2026 20:49
@github-actions github-actions bot locked and limited conversation to collaborators Mar 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cherry-pick/v2.31 Needs to be cherry-picked to the 2.31 release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants