Repository navigation
fix: keep http.DefaultTransport a *http.Transport for OPA http.send - #449
dgilman-perplexity wants to merge 1 commit into
Conversation
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. |
3936689 to
0bcfece
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3936689486
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
0bcfece to
3df166c
Compare
|
Addressed the two review findings in c5d94a3: removed the doc comment on the top-level test, and wired the Go module proxy's |
configureProcess replaced the global http.DefaultTransport with the BackoffTransport/OriginTransport wrapper so every strategy shared 429 cooldowns and origin metrics. OPA's http.send asserts http.DefaultTransport.(*http.Transport) whenever a policy sets a TLS option such as tls_ca_cert_file, so every policy evaluation that reached http.send panicked with "interface conversion: http.RoundTripper is *httputil.BackoffTransport, not *http.Transport" and net/http dropped the client connection. Install the wrapper through httputil.SetUpstreamTransport instead, and give every client that relied on the default transport or http.DefaultClient the shared transport explicitly via httputil.UpstreamTransport / httputil.UpstreamClient. Until a transport is installed the accessor forwards to the live http.DefaultTransport, so tests that swap the global to intercept upstream traffic keep working. The regression test runs a real http.send with tls_ca_cert_file after configureProcess in a child process; it fails with the panic above on the previous code. Co-authored-by: Perplexity <noreply@perplexity.ai> Signed-off-by: dgilman-perplexity <293900578+dgilman-perplexity@users.noreply.github.com>
3df166c to
c5d94a3
Compare
Problem
configureProcessreassigns the globalhttp.DefaultTransportto theBackoffTransport/OriginTransportwrapper (since #430) so every strategy shares 429 cooldowns and origin metrics. OPA'shttp.sendbuiltin doeshttp.DefaultTransport.(*http.Transport).Clone()whenever a policy passes a TLS option (tls_ca_cert_file,tls_ca_cert,tls_client_cert*,tls_server_name, or aHostheader), seev1/topdown/http.go. With the wrapper installed, every evaluation that reacheshttp.sendpanics:net/httprecovers the panic per connection, so the daemon stays healthy and passes readiness checks while every admitted request on such a policy fails. Settingupstream-backoffdoesn't help; any wrapper on the global trips the assertion.Fix
http.DefaultTransportis left as a*http.Transport. The cooldown/metrics wrapper is installed through a newhttputil.SetUpstreamTransport, and clients that previously relied on the default transport orhttp.DefaultClient(GitHub App tokens and API client, Hermit, Git reverse proxy, github-releases, host and its fallbacks, artifactory, proxy, OCI, Go module proxy and its sumdb client) now get it explicitly viahttputil.UpstreamTransport()/httputil.UpstreamClient(), so cooldown and origin-metric coverage is unchanged for them.UpstreamTransport()forwards to the livehttp.DefaultTransportat request time, so the existing tests that swap the global to intercept upstream traffic keep working unchanged.http.sendrequests without TLS options previously went through the cooldown wrapper (via the global) and now use the plain default transport, matching what its TLS path always did.Tests
cmd/cachewd/opa_transport_test.goruns a realhttp.sendwithtls_ca_cert_fileagainst anhttptestTLS server afterconfigureProcess, in a child process. Onmainit fails with the panic above; with this change it passes.internal/httputil/upstream_test.gocovers the fallback-to-global and installed-transport paths.go build ./...,go vet, andgo testoncmd/cachewd,internal/httputil,internal/githubapp,internal/strategy,internal/strategy/gomod,internal/opapass locally. Failures ininternal/strategy/gitandinternal/strategy/handlerare pre-existing in my environment (need Docker,pzstd, and git-lfs ≥ 3.8.1) and reproduce identically onmain.Created with Perplexity