Skip to content
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

Handle cancelation while establishing ssh connection #832

Merged
merged 1 commit into from
Feb 10, 2022

Conversation

michaeldwan
Copy link
Contributor

Fixes #830

Possibly relevant issue golang/go#20288

Seems like cancelation isn't being handled in ssh.NewClientConn. Comments on that issue indicate that cancelation will happen if the net.Conn being passed in is correctly closed on cancel. This is likely not happening as needed due to the way we pass in a connection from the agent's dialer.

Handling cancelation independently solves the issue for now.

@jsierles
Copy link
Member

Relevant to #831

@michaeldwan michaeldwan merged commit a1aa8f8 into master Feb 10, 2022
@michaeldwan michaeldwan deleted the handle-cancelation-during-ssh-dial branch February 10, 2022 19:13
c.conn, c.client = conn, ssh.NewClient(conn, chans, reqs)
return nil
// ssh.NewClientConn doesn't take a context, so we need to handle cancelation on our end
go func() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it'd be far simpler instead of launching this in the background, and since you already have a reference to the underlying connection, to just close it on context cancellation instead of this.

respCh <- connResp{nil, conn, client}
}()

for {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you looping?

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.

Can't cancel ssh console while waiting on host
3 participants