From 9dde02d660b5c0d63226e092d6cd1c4eef163e03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Tyczy=C5=84ski?= Date: Mon, 18 Jul 2022 21:13:33 +0200 Subject: [PATCH] Clean shutdown of client integration tests Kubernetes-commit: f673c262bdc2f3f0f060a2ed4349b723a088f36a --- transport/cache.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/transport/cache.go b/transport/cache.go index 5fe768ed..214f0a79 100644 --- a/transport/cache.go +++ b/transport/cache.go @@ -36,6 +36,11 @@ type tlsTransportCache struct { transports map[tlsCacheKey]*http.Transport } +// DialerStopCh is stop channel that is passed down to dynamic cert dialer. +// It's exposed as variable for testing purposes to avoid testing for goroutine +// leakages. +var DialerStopCh = wait.NeverStop + const idleConnsPerHost = 25 var tlsCache = &tlsTransportCache{transports: make(map[tlsCacheKey]*http.Transport)} @@ -101,7 +106,7 @@ func (c *tlsTransportCache) get(config *Config) (http.RoundTripper, error) { dynamicCertDialer := certRotatingDialer(tlsConfig.GetClientCertificate, dial) tlsConfig.GetClientCertificate = dynamicCertDialer.GetClientCertificate dial = dynamicCertDialer.connDialer.DialContext - go dynamicCertDialer.Run(wait.NeverStop) + go dynamicCertDialer.Run(DialerStopCh) } proxy := http.ProxyFromEnvironment