Merge pull request #75445 from shinytang6/enhance/fmt

Replace all time.Now().Sub with time.Since

Kubernetes-commit: 531dbd409f5b0000e54038f9736a3e148821a6eb
This commit is contained in:
Kubernetes Publisher 2019-03-26 13:55:17 -07:00
commit ad771aa269
4 changed files with 55 additions and 55 deletions

102
Godeps/Godeps.json generated
View File

@ -420,207 +420,207 @@
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting", "ImportPath": "k8s.io/apimachinery/pkg/api/apitesting",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/fuzzer", "ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/fuzzer",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/roundtrip", "ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/roundtrip",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/equality", "ImportPath": "k8s.io/apimachinery/pkg/api/equality",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/errors", "ImportPath": "k8s.io/apimachinery/pkg/api/errors",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/meta", "ImportPath": "k8s.io/apimachinery/pkg/api/meta",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/resource", "ImportPath": "k8s.io/apimachinery/pkg/api/resource",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1beta1", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1beta1",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/conversion", "ImportPath": "k8s.io/apimachinery/pkg/conversion",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams", "ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/fields", "ImportPath": "k8s.io/apimachinery/pkg/fields",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/labels", "ImportPath": "k8s.io/apimachinery/pkg/labels",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime", "ImportPath": "k8s.io/apimachinery/pkg/runtime",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/schema", "ImportPath": "k8s.io/apimachinery/pkg/runtime/schema",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/selection", "ImportPath": "k8s.io/apimachinery/pkg/selection",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/types", "ImportPath": "k8s.io/apimachinery/pkg/types",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/cache", "ImportPath": "k8s.io/apimachinery/pkg/util/cache",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/clock", "ImportPath": "k8s.io/apimachinery/pkg/util/clock",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/diff", "ImportPath": "k8s.io/apimachinery/pkg/util/diff",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/errors", "ImportPath": "k8s.io/apimachinery/pkg/util/errors",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/framer", "ImportPath": "k8s.io/apimachinery/pkg/util/framer",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream", "ImportPath": "k8s.io/apimachinery/pkg/util/httpstream",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy", "ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/intstr", "ImportPath": "k8s.io/apimachinery/pkg/util/intstr",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/json", "ImportPath": "k8s.io/apimachinery/pkg/util/json",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch", "ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/naming", "ImportPath": "k8s.io/apimachinery/pkg/util/naming",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/net", "ImportPath": "k8s.io/apimachinery/pkg/util/net",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand", "ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/runtime", "ImportPath": "k8s.io/apimachinery/pkg/util/runtime",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/sets", "ImportPath": "k8s.io/apimachinery/pkg/util/sets",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch", "ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/validation", "ImportPath": "k8s.io/apimachinery/pkg/util/validation",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/validation/field", "ImportPath": "k8s.io/apimachinery/pkg/util/validation/field",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/wait", "ImportPath": "k8s.io/apimachinery/pkg/util/wait",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/yaml", "ImportPath": "k8s.io/apimachinery/pkg/util/yaml",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/version", "ImportPath": "k8s.io/apimachinery/pkg/version",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/watch", "ImportPath": "k8s.io/apimachinery/pkg/watch",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json", "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil", "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect", "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect",
"Rev": "7b3d41122501114701f8d013ea1d9533f60c5dd5" "Rev": "4ceb6b6c5db56a2f8f454dd837c07160a3d6e131"
}, },
{ {
"ImportPath": "k8s.io/klog", "ImportPath": "k8s.io/klog",

View File

@ -363,7 +363,7 @@ loop:
} }
} }
watchDuration := r.clock.Now().Sub(start) watchDuration := r.clock.Since(start)
if watchDuration < 1*time.Second && eventCount == 0 { 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) return fmt.Errorf("very short watch: %s: Unexpected watch close - watch lasted less than a second and no items received", r.name)
} }

View File

@ -99,7 +99,7 @@ func (p *Backoff) IsInBackOffSince(id string, eventTime time.Time) bool {
if hasExpired(eventTime, entry.lastUpdate, p.maxDuration) { if hasExpired(eventTime, entry.lastUpdate, p.maxDuration) {
return false 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. // Returns True if time since lastupdate is less than the current backoff window.

View File

@ -114,14 +114,14 @@ func TestBackoffGC(t *testing.T) {
b.GC() b.GC()
_, found := b.perItemBackoff[id] _, found := b.perItemBackoff[id]
if !found { 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) tc.Step(maxDuration + step)
b.GC() b.GC()
r, found := b.perItemBackoff[id] r, found := b.perItemBackoff[id]
if found { 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)
} }
} }