Skip to content

Plug a goroutine leak.#661

Merged
brandond merged 3 commits into
rancher:mainfrom
ericpromislow:652-plug-goroutine-leak
May 5, 2026
Merged

Plug a goroutine leak.#661
brandond merged 3 commits into
rancher:mainfrom
ericpromislow:652-plug-goroutine-leak

Conversation

@ericpromislow

Copy link
Copy Markdown
Contributor

Applied @vvlisn's suggested fix from 652

@ericpromislow ericpromislow requested a review from a team as a code owner May 1, 2026 22:59
@brandond

brandond commented May 2, 2026

Copy link
Copy Markdown
Member

Question: are we confident that readers are going away because the context is cancelled? Are there any other conditions where the reader may stop reading, but the context continues to be valid?

Comment thread pkg/summary/client/simple.go
Comment thread pkg/summary/client/simple.go
eventChan <- event
select {
case eventChan <- event:
case <-ctx.Done():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this may fix the issue if the caller context is correctly canceled, I believe it should have its own context that gets canceled on Stop(). I believe we should create a derived context with WithCancel, then make Stop() cancel it, in addition to the embedded resp.Stop()

@brandond brandond May 4, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah... I agree. Relying on the embedded resp's Stop() to be called and handle everything seems fragile. watcher should implement its own Stop that ensures the context is cancelled to stop the goroutine.

@ericpromislow ericpromislow requested a review from brandond May 4, 2026 17:29
@ericpromislow

Copy link
Copy Markdown
Contributor Author

@aruiz14 Would you be able to take over from me? I only see how it's used from steve, and then I'm only really familar with running steve standalone, in which case it runs forever until it's killed, so nothing needs to be gracefully closed.

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
@brandond brandond force-pushed the 652-plug-goroutine-leak branch from d529bc7 to 4166a88 Compare May 4, 2026 18:49
@brandond

brandond commented May 4, 2026

Copy link
Copy Markdown
Member

@ericpromislow @aruiz14 how about that?

@brandond brandond requested a review from aruiz14 May 4, 2026 20:36
@brandond brandond merged commit 1e4486b into rancher:main May 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants