diff --git a/tools/cache/reflector.go b/tools/cache/reflector.go index c43b7fc5..a629fd4e 100644 --- a/tools/cache/reflector.go +++ b/tools/cache/reflector.go @@ -363,7 +363,7 @@ loop: } } - watchDuration := r.clock.Now().Sub(start) + watchDuration := r.clock.Since(start) if watchDuration < 1*time.Second && eventCount == 0 { return fmt.Errorf("very short watch: %s: Unexpected watch close - watch lasted less than a second and no items received", r.name) } diff --git a/util/flowcontrol/backoff.go b/util/flowcontrol/backoff.go index b7cb70ea..39cd72f9 100644 --- a/util/flowcontrol/backoff.go +++ b/util/flowcontrol/backoff.go @@ -99,7 +99,7 @@ func (p *Backoff) IsInBackOffSince(id string, eventTime time.Time) bool { if hasExpired(eventTime, entry.lastUpdate, p.maxDuration) { return false } - return p.Clock.Now().Sub(eventTime) < entry.backoff + return p.Clock.Since(eventTime) < entry.backoff } // Returns True if time since lastupdate is less than the current backoff window. diff --git a/util/flowcontrol/backoff_test.go b/util/flowcontrol/backoff_test.go index b14ab341..4d061d54 100644 --- a/util/flowcontrol/backoff_test.go +++ b/util/flowcontrol/backoff_test.go @@ -114,14 +114,14 @@ func TestBackoffGC(t *testing.T) { b.GC() _, found := b.perItemBackoff[id] if !found { - t.Errorf("expected GC to skip entry, elapsed time=%s maxDuration=%s", tc.Now().Sub(lastUpdate), maxDuration) + t.Errorf("expected GC to skip entry, elapsed time=%s maxDuration=%s", tc.Since(lastUpdate), maxDuration) } tc.Step(maxDuration + step) b.GC() r, found := b.perItemBackoff[id] if found { - t.Errorf("expected GC of entry after %s got entry %v", tc.Now().Sub(lastUpdate), r) + t.Errorf("expected GC of entry after %s got entry %v", tc.Since(lastUpdate), r) } }