Repository navigation
Conversation
|
Hi @bjencks. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: bjencks The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Calling rest.RESTClientFor on every poll with Proxy != nil creates a new uncached transport each time. When CertFile and KeyFile are configured without inline CertData/KeyData, client-go enables ReloadTLSFiles and starts a new certRotatingDialer and workqueue (4+ background goroutines) per poll, whose cancellation waits for GC via runtime.AddCleanup (or leaks permanently on client-go < v0.36 or when ClientsAllowTLSCacheGC is disabled). Lazily initialize a single dedicated RESTClient per apiServerMonitor instance (keeping Proxy != nil so tlsTransportCache is skipped even when ClientsAllowTLSCacheGC is disabled) and wrap its dialer with connrotation.NewDialer. Close connections before each check (in case a prior dial completed right after CloseAll) and via LIFO defers on return (cancel checkCtx, call CloseIdleConnectionsFor to evict idle connections from http.Transport's pool, then call connDialer.CloseAll() to actively close any remaining non-idle connections such as timed-out HTTP/2 streams).
SergeyKanzhelev
left a comment
There was a problem hiding this comment.
I am ok to lgtm as-is. But thinking more I am wondering if setting proxy doing anything now
| if kubeConfig.Proxy == nil { | ||
| // Explicitly set Proxy so client-go's tlsTransportCache (transport/cache.go: | ||
| // tlsConfigKey returns uncacheable when Proxy != nil) creates a fresh | ||
| // http.Transport on each RESTClientFor call instead of reusing a cached | ||
| // transport and its already-established TCP connection. TestCheckAPIServer's | ||
| // new-connection assertion acts as a canary if a client-go upgrade changes this. | ||
| // Set Proxy to bypass client-go's transport cache (undocumented behavior | ||
| // when Proxy != nil). A single RESTClient with a connrotation dialer is | ||
| // reused to avoid per-check cert-rotation goroutines and close all sockets. | ||
| kubeConfig.Proxy = http.ProxyFromEnvironment | ||
| } |
There was a problem hiding this comment.
nit: Proxy looks redundant with the dedicated dialer that isolates the transport. Are you sure we need it after this change?
|
/ok-to-test |
Calling rest.RESTClientFor on every poll with Proxy != nil creates a new uncached transport each time. When CertFile and KeyFile are configured without inline CertData/KeyData, client-go enables ReloadTLSFiles and starts a new certRotatingDialer and workqueue (4+ background goroutines) per poll, whose cancellation waits for GC via runtime.AddCleanup (or leaks permanently on client-go < v0.36 or when ClientsAllowTLSCacheGC is disabled).
Lazily initialize a single dedicated RESTClient per apiServerMonitor instance (keeping Proxy != nil so tlsTransportCache is skipped even when ClientsAllowTLSCacheGC is disabled) and wrap its dialer with connrotation.NewDialer. Close connections before each check (in case a prior dial completed right after CloseAll) and via LIFO defers on return (cancel checkCtx, call CloseIdleConnectionsFor to evict idle connections from http.Transport's pool, then call connDialer.CloseAll() to actively close any remaining non-idle connections such as timed-out HTTP/2 streams).