fix: stop ticker/timer in waitForMount to avoid leak#2465
Conversation
|
|
|
Welcome @dimbleby! |
|
Hi @dimbleby. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
26c620a to
2225263
Compare
waitForMount used time.Tick and time.After. time.Tick's underlying ticker is never garbage collected per the Go documentation, so every blobfuse mount leaked a runtime ticker that kept firing after the function returned. On the timeout path the ticker would continue to tick forever. Use time.NewTicker and time.NewTimer with deferred Stop so resources are released when the function returns.
2225263 to
dfc6c3a
Compare
There was a problem hiding this comment.
Pull request overview
Fixes a runtime resource leak in waitForMount by replacing time.Tick/time.After (which prevent the underlying ticker/timer from being garbage-collected) with time.NewTicker/time.NewTimer paired with deferred Stop() calls.
Changes:
- Replace
time.Tick(intervel)withtime.NewTicker+defer ticker.Stop(). - Replace
time.After(timeout)withtime.NewTimer+defer timer.Stop().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
/ok-to-test |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andyzhangx, dimbleby The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/cherrypick release-1.27 |
|
@andyzhangx: new pull request created: #2471 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
What type of PR is this?
/kind bug
What this PR does / why we need it:
waitForMount used time.Tick and time.After. time.Tick's underlying ticker is never garbage collected per the Go documentation, so every blobfuse mount leaked a runtime ticker that kept firing after the function returned. On the timeout path the ticker would continue to tick forever.
Use time.NewTicker and time.NewTimer with deferred Stop so resources are released when the function returns.
Which issue(s) this PR fixes:
Requirements:
Special notes for your reviewer:
Release note: