Repository navigation
Conversation
…probing The streamable proxy tests probed a free port with bind-close-rebind (getFreePort/pickFreePort) and then bound the proxy to it later, leaving a TOCTOU window (documented in stacklok#6034/stacklok#6044, ~0.08% collisions under churn). Eliminate the pattern at the source: - Start() binds synchronously when the port is 0 and exposes the real address via a new Address() accessor, so callers can hand the proxy port 0 and read the bound address back. - Tests now construct proxies with port 0 and build URLs from proxy.Address(); the getFreePort/pickFreePort helpers and the port-typed test helpers (startProxyWithBackend, startProxyOnly, establishSession, openGETStream, postSSE, postJSON, startInitTestProxy) are gone. - A comment at each former helper site explains why the probe-listener pattern must not be reintroduced (per stacklok#6044 precedent).
suantea
requested review from
ChrisJBurns,
JAORMX,
amirejaz,
blkt,
jhrozek and
rdimitrov
as code owners
October 11, 2026 01:01
Contributor
|
Hi @suantea, I'm closing this PR along with the rest of this batch. Nothing personal, it's just not how we're set up to take contributions. Our contributing guide asks you to comment on an issue and wait for someone on the team to assign it to you before you start. We do that so two people don't end up fixing the same thing, and so we can agree on the approach first. A few of these PRs landed on issues that already had someone assigned, and I can't review 20+ PRs across unrelated parts of the codebase from one person anyway. If you'd like to contribute, please read CONTRIBUTING.md, pick one issue, and ask to be assigned. A |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6045 — the second
getFreePortbind-close-rebind (TOCTOU) race in the streamable proxy tests, same shape as the one #6034 documented and #6044 fixed in the vMCP copy.What changed
NewHTTPProxy(host, 0, ...)+Start()now binds synchronously on an OS-assigned port, and the proxy exposes the real bound address via a newAddress()accessor — the same shape #6044 used for vMCP. The tests stop probing ports entirely:Start()binds the listener synchronously when the port is 0 and setsserver.Addrfrom the listener, soAddress()is valid as soon asStartreturns. Configured ports keep their previousListenAndServebehaviour.streamable_proxy_integration_test.go: deletedgetFreePort(the helper Second getFreePort bind-close-rebind race in streamable proxy tests #6045 names) andstreamable_proxy_spec_test.go: deletedpickFreePort.startProxyWithBackend/startProxyOnlytake no port and bind 0;establishSession/openGETStream/postSSE/postJSON/startInitTestProxytake*HTTPProxyand build URLs fromAddress().This removes the race for every test in the package at once — fixing just the two helpers would have left the same TOCTOU shape in the other call sites.
Verification
go test -race -count=1 ./pkg/transport/proxy/streamable/— passgo build ./...— cleangofmt/go vet— clean