Repository navigation
Conversation
… transport The reporter shares http.DefaultTransport. A CloseIdleConnections call on it while a bodyless 202 response is between the idle pool and the caller fails the request, so the deployment POST errors and no snapshot follows. The hook forces that window. Both tests fail until the reporter owns its transport. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_
The reporter used http.DefaultTransport. Any CloseIdleConnections call on it in the same process, for example cli/server.go on shutdown or httptest.Server.Close in a parallel test, could fail a telemetry request whose bodyless 202 response was just returning its connection to the pool. The reporter now clones the default transport and closes its own idle connections in Close, which the shared defer in cli/server.go used to do for it. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_
Replaces the first two tests and the isolation test of the previous commit with one test. It closes the idle connections of the default transport between two reports, then checks that the reporter reused its connection, and that Close releases it. It fails for each of: the old shared client, a clone step that is dropped, and a Close that does not close the pool. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_
|
@codex review |
|
@codex security review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
…ction The reporter test only waited for the first connection to close, so a Close that released the pool before its final report passed. Count the server's new and closed connections and require them to match after Close.
|
@codex review |
|
@codex security review |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a3d124fe13
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The test clones a database, sends three reports and polls for every connection to close. Repository testing guidance asks for testutil.WaitLong. _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
ethanndickson
left a comment
There was a problem hiding this comment.
Could we drop the new test and inline the clone instead of adding another helper? Details inline.
Generated by an agent on behalf of the user
| func newHTTPClient() *http.Client { | ||
| transport := &http.Transport{Proxy: http.ProxyFromEnvironment} | ||
| if defaultTransport, ok := http.DefaultTransport.(*http.Transport); ok { | ||
| transport = defaultTransport.Clone() | ||
| } | ||
| return &http.Client{Transport: transport} | ||
| } |
There was a problem hiding this comment.
We already have this same clone in a bunch of places (coderdtest.NewIsolatedHTTPClient, newHTTPTransport in cli/root.go, both mcpHTTPClients). Could we skip another helper and just inline it in New? Something like:
if transport, ok := http.DefaultTransport.(*http.Transport); ok {
reporter.client.Transport = transport.Clone()
}Generated by an agent on behalf of the user
| // deployment report then errors and no snapshot follows. The reporter must | ||
| // keep its connection through such a close, and Close must release every | ||
| // connection the reporter opened, the one for its final report included. | ||
| func TestTelemetry_ReporterOwnsConnectionPool(t *testing.T) { |
There was a problem hiding this comment.
Could we delete this test? It doesn't reproduce the race: on the old client both reports still succeed and only the connection count differs, so it's really just checking which pool the client uses. The earlier fixes for this flake (#19462, #23494) didn't add one either.
Generated by an agent on behalf of the user
- TestTelemetry_ReporterOwnsConnectionPool: replace the local messageSink and waitForMessage helpers with testutil.FakeSink and testutil.Eventually. The test keeps the same client-side completion signal, the "submitted snapshot" log line, and the same two guards: reuse of the reporter's connection after http.DefaultClient.CloseIdleConnections, and release of every connection on Close.
- M3, TestTelemetry_ReporterOwnsConnectionPool: wrap the waitSubmitted wait in require.True, so a missed wait fails the test at once and does not run on with an expired context. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Why
A CI run on an Automations PR (#32140) found a flake on main.
TestServer_TelemetryDisabled_FinalReportfailed once because the server's first telemetry POST returnednet/http: HTTP/1.x transport connection broken: http: CloseIdleConnections called. The deployment report errored, no snapshot followed, and the test waited forsubmitted snapshotuntil its deadline.The telemetry reporter used
http.DefaultTransport, which every client without its own transport shares. net/http returns the connection of a response without a body, like the telemetry server's 202, to the idle pool before it hands the response to the caller. ACloseIdleConnectionscall on the same transport inside that gap fails a request that already succeeded.cli/server.gomakes that call when a server stops, andhttptest.Server.Closemakes it too. Many parallelclitests use both.What changed
The reporter builds its client on a clone of the default transport, so it has its own connection pool, and
Closecloses that pool's idle connections. Thedefer http.DefaultClient.CloseIdleConnections()incli/server.gostays, because it cleans up the embedded-postgres idle connection that goleak catches (#3246).Scope
This covers the telemetry reporter, the one client with evidence of the failure. It does not touch other clients of the default transport or the
cli/server.godefer.Tradeoffs
Narrowing the
cli/server.godefer to clients the server owns would not remove the cause.httptest.Server.Closeand tests that close their codersdk clients (default transport) still close the shared pool's idle connections.The gap is too narrow to hit by looping: 100 runs of the
clitest pass on main and on this branch. A forced reproduction (aPutIdleConntrace hook that closes the default transport's idle connections and holds the response) fails the old reporter with the CI error on every run. The new testTestTelemetry_ReporterOwnsConnectionPoolfails on the old code, on a shared client, on a missing clone, on aClosethat keeps the pool, and on aClosethat releases the pool before its final report.If a report is still in flight over HTTP/2 when
Closeruns, its connection stays open until the transport's 90 s idle timeout. Both production callers ofCloserun at process exit, so this is one socket in an exiting process. Turning off keep-alives would close it at once and give up connection reuse within a report.Live check: none. The change is limited to the reporter's HTTP client, and the
cliandenterprise/cliserver tests run it.Generated with
xum• Model:anthropic:claude-sonnet-5-5• Thinking:xhigh