Skip to content

fix(agent/agentssh): close silent ssh connections and report a network error - #32521

Closed
EhabY wants to merge 1 commit into
mainfrom
fix/agentssh-connection-keepalive
Closed

EhabY wants to merge 1 commit into
mainfrom
fix/agentssh-connection-keepalive

Conversation

@EhabY

@EhabY EhabY commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Bumps the gliderlabs/ssh fork to coder/ssh#8, which runs the server keep-alive once per connection and closes the whole connection when the client stops answering. Before, the timeout closed only the session channel and stopped with the first session, so the connection and its "Ongoing" connection log row could stay open indefinitely.

  • Same 72h default: the fork now counts like OpenSSH (closes after CountMax+1 intervals without a reply), so CODER_AGENT_SSH_MAX_TIMEOUT is divided by 4 instead of 3.
  • Disconnect reason: a connection closed by the keep-alive is reported as network_error instead of client_closed, using the fork's SessionKeepAlive.TimedOut().
  • Docs: connection-logs.md explains the timeout and the tradeoff of lowering it.

Important

go.mod points at the PR head on EhabY/ssh for now. It will be repointed to coder/ssh once coder/ssh#8 merges.

Refs CLIENT-1113.

Verification

TestSSHServer_KeepAliveClosesSilentConnection/AgentKeepAlive (MaxTimeout 3s, client stops sending) passes in about 4s and reports network_error. It fails with client_closed when the TimedOut mapping is removed, and does not build against the old fork.

$ go test -race -count=1 ./agent/agentssh/
ok  	github.com/coder/coder/v2/agent/agentssh	9.046s
$ go test -count=1 ./agent/
ok  	github.com/coder/coder/v2/agent	18.433s
$ go test -count=1 -run SSH ./cli/
ok  	github.com/coder/coder/v2/cli	24.839s
$ golangci-lint run ./agent/agentssh/...
0 issues.
$ vale docs/admin/monitoring/connection-logs.md
✔ 0 errors, 0 warnings and 0 suggestions in 1 file.
Decision log
  • Keep 72h rather than accept 96h: the flag's description and the tailnet TCP keep-alive (72h + 1min) assume it.
  • TimedOut is read inside the sync.Once report, so both report paths (connection close and process exit) agree. It is set before the connection closes, so any report after the close sees it.
  • feat(agent/agentssh): let clients shorten the ssh keep-alive interval #32444 builds on this to let clients shorten the keep-alive per connection through the same fork API.

Written with Coder Agents and reviewed by @EhabY.

@linear-code

linear-code Bot commented Nov 20, 2026

Copy link
Copy Markdown

CLIENT-1113

@EhabY

EhabY commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator Author

Folded into #32444 so the fork bump and the client opt-in land together.

Written with Coder Agents and reviewed by @EhabY.

@EhabY EhabY closed this Nov 20, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 20, 2026
@EhabY
EhabY deleted the fix/agentssh-connection-keepalive branch November 23, 2026 10:25

This branch had an error being deployed

1 failed and 1 inactive deployments
main — e72e48b2 Deployed Nov 20, 2026 by EhabY via cla #260868
docs-preview — e72e48b2 Deployed Nov 20, 2026 by EhabY via cleanup #276
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant