-
Notifications
You must be signed in to change notification settings - Fork 936
fix(agent/agentssh): allow remote forwarding a socket multiple times #11631
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
5ce1baf
to
96c0724
Compare
96c0724
to
dab6034
Compare
// Ensure the SSH connection is ready by testing the shell | ||
// input/output. | ||
pty.WriteLine("echo ping' 'pong") | ||
pty.ExpectMatchContext(ctx, "ping pong") |
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.
using the CLI to test the agent is awkward and this is an example. This test would be easier to write and easier to understand if were in agent_test.go
and we could use the go ssh client.
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 do somewhat agree, but I'm not sure agent_test.go
is a much better place since the actual forwarding is implemented here, in cli/remoteforward.go
. This test should ensure that the behavior we want works with the actual coder ssh
client.
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.
We already have tests for coder ssh
in terms of making a unix socket remote forward and verifying it works. None of that behavior is changing in this PR.
What's changing is on the agent side of the connection. And it's not just coder ssh
that talks to that SSH server: it could be OpenSSH or JetBrains Gateway or VSCode (via coder ssh --stdio
), or even a custom SSH client written in go using codersdk
. Therefore, we need to think about the required behavior in terms of what the SSH server is supposed to do, not just end-to-end with a specific client.
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.
Yeah, I'm not opposed tbh. I think the best place for most of this testing is within the agentssh
package itself. I'll create an issue for this since if we go this route, there's some other restructuring that needs to be done as well. Like moving the forwarding logic from cli
to agentssh
, etc. Otherwise I think we'll end up with "many implementations of an SSH client".
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.
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.
One thing to fixup; but I don't need to review again.
Fixes #11198
Fixes https://github.com/coder/customers/issues/407
For this PR, I implemented a new test in
cli/ssh_test.go
, however, in future, we should consider doing more extensive testing for forwarding within theagent/agentssh
package.