From 1a598798fca6f15f4e883368666e7d4d3565fcc6 Mon Sep 17 00:00:00 2001 From: tanjing2020 Date: Fri, 23 Jul 2021 10:26:26 +0800 Subject: [PATCH] Replace with --- staging/src/k8s.io/apimachinery/pkg/util/wait/wait_test.go | 4 ++-- .../plugin/pkg/authenticator/token/webhook/webhook.go | 2 +- .../k8s.io/apiserver/plugin/pkg/authorizer/webhook/webhook.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/staging/src/k8s.io/apimachinery/pkg/util/wait/wait_test.go b/staging/src/k8s.io/apimachinery/pkg/util/wait/wait_test.go index dbd3dfbda39..01c33ffcda4 100644 --- a/staging/src/k8s.io/apimachinery/pkg/util/wait/wait_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/util/wait/wait_test.go @@ -753,7 +753,7 @@ func TestJitterBackoffManagerWithRealClock(t *testing.T) { for i := 0; i < 5; i++ { start := time.Now() <-backoffMgr.Backoff().C() - passed := time.Now().Sub(start) + passed := time.Since(start) if passed < 1*time.Millisecond { t.Errorf("backoff should be at least 1ms, but got %s", passed.String()) } @@ -768,7 +768,7 @@ func TestExponentialBackoffManagerWithRealClock(t *testing.T) { for i := range durationFactors { start := time.Now() <-backoffMgr.Backoff().C() - passed := time.Now().Sub(start) + passed := time.Since(start) if passed < durationFactors[i]*time.Millisecond { t.Errorf("backoff should be at least %d ms, but got %s", durationFactors[i], passed.String()) } diff --git a/staging/src/k8s.io/apiserver/plugin/pkg/authenticator/token/webhook/webhook.go b/staging/src/k8s.io/apiserver/plugin/pkg/authenticator/token/webhook/webhook.go index 0cafa4d73e4..af7f0775755 100644 --- a/staging/src/k8s.io/apiserver/plugin/pkg/authenticator/token/webhook/webhook.go +++ b/staging/src/k8s.io/apiserver/plugin/pkg/authenticator/token/webhook/webhook.go @@ -137,7 +137,7 @@ func (w *WebhookTokenAuthenticator) AuthenticateToken(ctx context.Context, token start := time.Now() result, statusCode, tokenReviewErr = w.tokenReview.Create(ctx, r, metav1.CreateOptions{}) - latency := time.Now().Sub(start) + latency := time.Since(start) if statusCode != 0 { w.metrics.RecordRequestTotal(ctx, strconv.Itoa(statusCode)) diff --git a/staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/webhook.go b/staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/webhook.go index b7970139306..4dd08c45e4f 100644 --- a/staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/webhook.go +++ b/staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/webhook.go @@ -206,7 +206,7 @@ func (w *WebhookAuthorizer) Authorize(ctx context.Context, attr authorizer.Attri start := time.Now() result, statusCode, sarErr = w.subjectAccessReview.Create(ctx, r, metav1.CreateOptions{}) - latency := time.Now().Sub(start) + latency := time.Since(start) if statusCode != 0 { w.metrics.RecordRequestTotal(ctx, strconv.Itoa(statusCode))