From f2950329914ac210f4bde9005d80a97144814ec5 Mon Sep 17 00:00:00 2001 From: HaoJie Liu Date: Thu, 7 Jul 2022 18:58:25 +0800 Subject: [PATCH] fix static-check for staging/src/k8s.io/client-go/ Signed-off-by: HaoJie Liu Kubernetes-commit: 6022b69dfd1c6e9454d4aa79012803c749706f6d --- transport/round_trippers.go | 10 +++++----- util/connrotation/connrotation_test.go | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/transport/round_trippers.go b/transport/round_trippers.go index 26a89f93..e2d1dcc9 100644 --- a/transport/round_trippers.go +++ b/transport/round_trippers.go @@ -491,7 +491,7 @@ func (rt *debuggingRoundTripper) RoundTrip(req *http.Request) (*http.Response, e DNSDone: func(info httptrace.DNSDoneInfo) { reqInfo.muTrace.Lock() defer reqInfo.muTrace.Unlock() - reqInfo.DNSLookup = time.Now().Sub(dnsStart) + reqInfo.DNSLookup = time.Since(dnsStart) klog.Infof("HTTP Trace: DNS Lookup for %s resolved to %v", host, info.Addrs) }, // Dial @@ -503,7 +503,7 @@ func (rt *debuggingRoundTripper) RoundTrip(req *http.Request) (*http.Response, e ConnectDone: func(network, addr string, err error) { reqInfo.muTrace.Lock() defer reqInfo.muTrace.Unlock() - reqInfo.Dialing = time.Now().Sub(dialStart) + reqInfo.Dialing = time.Since(dialStart) if err != nil { klog.Infof("HTTP Trace: Dial to %s:%s failed: %v", network, addr, err) } else { @@ -517,7 +517,7 @@ func (rt *debuggingRoundTripper) RoundTrip(req *http.Request) (*http.Response, e TLSHandshakeDone: func(_ tls.ConnectionState, _ error) { reqInfo.muTrace.Lock() defer reqInfo.muTrace.Unlock() - reqInfo.TLSHandshake = time.Now().Sub(tlsStart) + reqInfo.TLSHandshake = time.Since(tlsStart) }, // Connection (it can be DNS + Dial or just the time to get one from the connection pool) GetConn: func(hostPort string) { @@ -526,7 +526,7 @@ func (rt *debuggingRoundTripper) RoundTrip(req *http.Request) (*http.Response, e GotConn: func(info httptrace.GotConnInfo) { reqInfo.muTrace.Lock() defer reqInfo.muTrace.Unlock() - reqInfo.GetConnection = time.Now().Sub(getConn) + reqInfo.GetConnection = time.Since(getConn) reqInfo.ConnectionReused = info.Reused }, // Server Processing (time since we wrote the request until first byte is received) @@ -538,7 +538,7 @@ func (rt *debuggingRoundTripper) RoundTrip(req *http.Request) (*http.Response, e GotFirstResponseByte: func() { reqInfo.muTrace.Lock() defer reqInfo.muTrace.Unlock() - reqInfo.ServerProcessing = time.Now().Sub(serverStart) + reqInfo.ServerProcessing = time.Since(serverStart) }, } req = req.WithContext(httptrace.WithClientTrace(req.Context(), trace)) diff --git a/util/connrotation/connrotation_test.go b/util/connrotation/connrotation_test.go index 29a37d58..1f529060 100644 --- a/util/connrotation/connrotation_test.go +++ b/util/connrotation/connrotation_test.go @@ -100,7 +100,7 @@ func TestCloseAllRace(t *testing.T) { dialer.CloseAll() // Expect all connections to close within 5 seconds - for start := time.Now(); time.Now().Sub(start) < 5*time.Second; time.Sleep(10 * time.Millisecond) { + for start := time.Now(); time.Since(start) < 5*time.Second; time.Sleep(10 * time.Millisecond) { // Ensure all connections were closed if c := atomic.LoadInt64(&conns); c == 0 { break