Skip to content

fix: detect and retry reverse port forward on used port #10844

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

Merged
merged 1 commit into from
Nov 27, 2023

Conversation

spikecurtis
Copy link
Contributor

Fixes #10799

The flake happens when we try to remote forward, but the port we've chosen is not free. In the flaked example, it's actually the SSH listener that occupies the port we try to remote forward, leading to confusing reads (c.f. the linked issue).

This fix simplies the tests considerably by using the Go ssh client, rather than shelling out to OpenSSH. This avoids using a pseudoterminal, avoids the need for starting any local OS listeners to communicate the forwarding (go SSH just returns in-process listeners), and avoids an OS listener to wire OpenSSH up to the agentConn.

With the simplied logic, we can immediately tell if a remote forward on a random port fails, so we can do this in a loop until success or timeout.

I've also simplified and fixed up the other forwarding tests. Since we set up forwarding in-process with Go ssh, we can remove a lot of the require.Eventually logic.

Copy link
Contributor Author

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

max = 60999
)
n := max - min
x := rand.Intn(n)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
x := rand.Intn(n)
x := rand.Intn(n) //nolint:gosec

@spikecurtis spikecurtis force-pushed the spike/10799-remote-forward-flake branch from 6c0dbe8 to 018b9e6 Compare November 23, 2023 12:28
@spikecurtis spikecurtis merged commit 6c67add into main Nov 27, 2023
@spikecurtis spikecurtis deleted the spike/10799-remote-forward-flake branch November 27, 2023 05:42
Copy link
Contributor Author

Merge activity

@github-actions github-actions bot locked and limited conversation to collaborators Nov 27, 2023
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.

flake: TestAgent_TCPRemoteForwarding
3 participants