Merge pull request #29596 from matttproud/fix/time-leaks/remainder

Automatic merge from submit-queue

pkg/various: plug leaky time.New{Timer,Ticker}s

According to the documentation for Go package time, `time.Ticker` and
`time.Timer` are uncollectable by garbage collector finalizers.  They
leak until otherwise stopped.  This commit ensures that all remaining
instances are stopped upon departure from their relative scopes.

Similar efforts were incrementally done in #29439 and #29114.

```release-note
* pkg/various: plugged various time.Ticker and time.Timer leaks.
```
This commit is contained in:
k8s-merge-robot
2016-07-29 14:06:47 -07:00
committed by GitHub
6 changed files with 7 additions and 0 deletions

View File

@@ -363,6 +363,7 @@ func checkEvents(t *testing.T, expectedEvents []string, ctrl *PersistentVolumeCo
// Read recorded events - wait up to 1 minute to get all the expected ones
// (just in case some goroutines are slower with writing)
timer := time.NewTimer(time.Minute)
defer timer.Stop()
fakeRecorder := ctrl.eventRecorder.(*record.FakeRecorder)
gotEvents := []string{}