mirror of https://github.com/k3s-io/k3s
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. ```pull/6/head
commit
75c93b4063
|
@ -223,8 +223,10 @@ func (b flockerMounter) updateDatasetPrimary(datasetID, primaryUUID string) erro
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
timeoutChan := time.NewTimer(timeoutWaitingForVolume).C
|
timeoutChan := time.NewTimer(timeoutWaitingForVolume)
|
||||||
tickChan := time.NewTicker(tickerWaitingForVolume).C
|
defer timeoutChan.Stop()
|
||||||
|
tickChan := time.NewTicker(tickerWaitingForVolume)
|
||||||
|
defer tickChan.Stop()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
if s, err := b.client.GetDatasetState(datasetID); err == nil && s.Primary == primaryUUID {
|
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 {
|
select {
|
||||||
case <-timeoutChan:
|
case <-timeoutChan.C:
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
"Timed out waiting for the dataset_id: '%s' to be moved to the primary: '%s'\n%v",
|
"Timed out waiting for the dataset_id: '%s' to be moved to the primary: '%s'\n%v",
|
||||||
datasetID, primaryUUID, err,
|
datasetID, primaryUUID, err,
|
||||||
)
|
)
|
||||||
case <-tickChan:
|
case <-tickChan.C:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue