Skip to content

Commit 3790b69

Browse files
authored
fix(control-plane): wire ProxyFromEnvironment into default HTTP transport (#1162)
## Summary - `installServiceCAIntoDefaultTransport` replaced `http.DefaultTransport` with a bare `&http.Transport{TLSClientConfig: ...}` — no `Proxy` field set - Go's `net/http` silently ignores `HTTPS_PROXY`/`HTTP_PROXY` env vars when the transport's `Proxy` field is `nil`, causing all outbound connections to go direct - This caused the OIDC token fetch to `sso.redhat.com` to time out after ~9 minutes (raw TCP connect timeout) despite proxy env vars being present on the pod ## Root cause ```go // Before — Proxy field absent → env vars silently ignored http.DefaultTransport = &http.Transport{ TLSClientConfig: &tls.Config{...}, } // After — proxy wired + standard DefaultTransport fields restored http.DefaultTransport = &http.Transport{ Proxy: http.ProxyFromEnvironment, DialContext: (&net.Dialer{Timeout: 30*time.Second, KeepAlive: 30*time.Second}).DialContext, ForceAttemptHTTP2: true, MaxIdleConns: 100, IdleConnTimeout: 90 * time.Second, TLSHandshakeTimeout: 10 * time.Second, ExpectContinueTimeout: 1 * time.Second, TLSClientConfig: &tls.Config{MinVersion: tls.VersionTLS12, RootCAs: pool}, } ``` The dialer/timeout fields were also zeroed out by the bare struct initializer, which degraded connection pooling and timeout behavior for all HTTP calls. ## Test plan - [ ] Deploy updated control-plane image to MPP dev cluster - [ ] Confirm OIDC token fetch succeeds (no 9-minute timeout in logs) - [ ] Verify `component: oidc-token-provider` log shows "OIDC token acquired" within seconds 🤖 Generated with [Claude Code](https://claude.ai/code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Enhanced connection management and timeout configuration to improve control plane reliability and stability. Updates include optimized connection pooling, improved proxy handling, and refined timeout settings for more robust performance. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 parents 7202c50 + f729006 commit 3790b69

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

  • components/ambient-control-plane/cmd/ambient-control-plane

components/ambient-control-plane/cmd/ambient-control-plane/main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import (
55
"crypto/tls"
66
"crypto/x509"
77
"fmt"
8+
"net"
89
"net/http"
910
"os"
1011
"os/signal"
1112
"syscall"
13+
"time"
1214

1315
"github.com/ambient-code/platform/components/ambient-control-plane/internal/auth"
1416
"github.com/ambient-code/platform/components/ambient-control-plane/internal/config"
@@ -216,6 +218,13 @@ func loadServiceCAPool() *x509.CertPool {
216218

217219
func installServiceCAIntoDefaultTransport(pool *x509.CertPool) {
218220
http.DefaultTransport = &http.Transport{
221+
Proxy: http.ProxyFromEnvironment,
222+
DialContext: (&net.Dialer{Timeout: 30 * time.Second, KeepAlive: 30 * time.Second}).DialContext,
223+
ForceAttemptHTTP2: true,
224+
MaxIdleConns: 100,
225+
IdleConnTimeout: 90 * time.Second,
226+
TLSHandshakeTimeout: 10 * time.Second,
227+
ExpectContinueTimeout: 1 * time.Second,
219228
TLSClientConfig: &tls.Config{
220229
MinVersion: tls.VersionTLS12,
221230
RootCAs: pool,

0 commit comments

Comments
 (0)