Commit 75c93b40 authored by k8s-merge-robot's avatar k8s-merge-robot Committed by GitHub

Merge pull request #29439 from matttproud/cleanups_volumeflocker

Automatic merge from submit-queue volume/flocker: plug time.Ticker resource leak This commit ensures that `flockerMounter.updateDatasetPrimary` does not leak running `time.Ticker` instances. Upon termination of the consuming routine, we stop the tickers. ```release-note * flockerMounter.updateDatasetPrimary no longer leaks running time.Ticker instances. Upon termination of the consuming routine, we stop the tickers. ```
parents ab7d039c dbba1347
......@@ -223,8 +223,10 @@ func (b flockerMounter) updateDatasetPrimary(datasetID, primaryUUID string) erro
return err
}
timeoutChan := time.NewTimer(timeoutWaitingForVolume).C
tickChan := time.NewTicker(tickerWaitingForVolume).C
timeoutChan := time.NewTimer(timeoutWaitingForVolume)
defer timeoutChan.Stop()
tickChan := time.NewTicker(tickerWaitingForVolume)
defer tickChan.Stop()
for {
if s, err := b.client.GetDatasetState(datasetID); err == nil && s.Primary == primaryUUID {
......@@ -232,12 +234,12 @@ func (b flockerMounter) updateDatasetPrimary(datasetID, primaryUUID string) erro
}
select {
case <-timeoutChan:
case <-timeoutChan.C:
return fmt.Errorf(
"Timed out waiting for the dataset_id: '%s' to be moved to the primary: '%s'\n%v",
datasetID, primaryUUID, err,
)
case <-tickChan:
case <-tickChan.C:
break
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment