-
Notifications
You must be signed in to change notification settings - Fork 937
feat: replace ssh maxTimeout with keep-alive mechanism #8062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
aa3744d
to
8334f26
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Such a small change. ❤️
cli/agent.go
Outdated
Default: "0", | ||
Flag: "ssh-max-timeout", | ||
// tcpip.KeepaliveIdleOption = 72h (forwardTCPSockOpts() in tailnet/conn.go) | ||
Default: fmt.Sprintf("%v", 72*time.Hour-time.Minute), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two thoughts:
- How about we set this to an even 72h, but do the subtraction elsewhere? I think the even number will be easier for users to understand
- Or, we could bump the tailnet conn keepalive slightly to account for this
- Perhaps the description should mention this is the maximum sensible value for this field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I set it to 72h, and changed
tcpip.KeepaliveIdleOption
to 72h + 1min as it seems straightforward to me. I guess that it doesn't make any difference that we elongate the TCP timeout by 1 minute. - Done (range: 60s - 72h).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I don't have any issues with this change, but will defer to @mafredri for approval.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Fixes: #7512
Fixes: #7581
This PR enables Keep-Alive support for SSH connections instead of
MaxTimeout
.The previous fix mentioned in this PR did not effectively address the issue with the VS Code extension. The problem arose when there was no activity (neither read nor write operations), causing the agent to terminate the connection after 1 minute. This pull request modifies the behavior to allow the client to respond to pings before terminating the connection, and keeping the connection alive.
How I tested this:
CODER_AGENT_SSH_MAX_TIMEOUT
to 60s or modifyssh-max-timeout
.Default in the source code../script/develop.sh
ssh coder.workspace-2 -vvv
<- observe pings every 20s./scripts/coder-dev.sh ssh workspace-2
<- leave the terminal without activity for more than 1 minute, the shell is still alive