Skip to content

Conversation

@fioan89
Copy link
Collaborator

@fioan89 fioan89 commented Jan 19, 2026

For a bit of context Coder Toolbox can establish an SSH connection when the workspace
is in RUNNING state and agent is in READY state. If the connection is already established
but for some reason the agent does not respond to pings, then the connection is terminated
by signaling Toolbox that the workspace changed the overall status to a non-reachable state.

In reality the connection can still work. After some code research and testing it looks like
coder ssh waits for the agent to be connecting before establishing the ssh connection. This
allows us to mark the workspace as reachable as soon as it hits the RUNNING state regardless
of the agent status.

The PR also changes the log level from debug to info for the lines that report the workspace and agent status.
This change should help with faster debugs in the future. Logs will not be spammed every 5 seconds with
this report, instead the line will be logging only when the workspace build changes.

Workspace and/or agent status change should be printed on
INFO level, because it is critical information that can help
us debug transient changes that can disrupt the ssh connection.
convert from enum to sealed class in order to be
able to store the workspace parameter which will
be used later to decide whether a workspace
is reachable via ssh.
…d/timed out

For a bit of context Coder Toolbox can establish an SSH connection when the workspace
is in RUNNING state and agent is in READY state. If the connection is already established
but for some reason the agent does not respond to pings, then the connectio is terminated
by signaling Toolbox that the workspace changed the overall status to a non-reachable state.

In reality the connection can still work. After some code research and testing it looks like
coder ssh waits for the agent to be connecting before establishing the ssh connection. This
allows us to mark the workspace as reachable as soon as it hits the RUNNING state regardless
of the agent status.

- resolves #246
@fioan89 fioan89 changed the title Fix ssh disconnects when agent is unhealthy fix: SSH connection is terminated when agent is marked as disconnected/timed out Jan 19, 2026
@fioan89 fioan89 marked this pull request as ready for review January 20, 2026 06:58
@fioan89 fioan89 merged commit 1f68be9 into main Jan 20, 2026
6 checks passed
@fioan89 fioan89 deleted the fix-ssh-disconnects-when-agent-is-unhealthy branch January 20, 2026 17:34
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.

SSH unnecessarily terminated if agent is marked DISCONNECTED by coderd

3 participants