mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
Merge pull request #103863 from tanjing2020/time
Replace `time.Now().Sub(x)` with `time.Since(x)`
This commit is contained in:
commit
35aa669145
@ -754,7 +754,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())
|
||||
}
|
||||
@ -769,7 +769,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())
|
||||
}
|
||||
|
@ -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))
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user