Replace with

This commit is contained in:
tanjing2020 2021-07-23 10:26:26 +08:00
parent 8ac0fcdb74
commit 1a598798fc
3 changed files with 4 additions and 4 deletions

View File

@ -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())
}

View File

@ -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))

View File

@ -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))