-
Notifications
You must be signed in to change notification settings - Fork 5k
fix(add_kubernetes_metadata): wait for init to complete during close #47662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
prevent goroutine leak and wait for init to complete when closing the processor
🤖 GitHub commentsJust comment with:
|
|
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
|
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
| if k.cache != nil { | ||
| k.cache.stop() | ||
| } | ||
| k.initOnce.Do(func() {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to double-check, you're trying to avoid the situation where Close is called while init is still executing.
So, in that case, shouldn't this call be the 1st thing, to ensure:
- close only runs after init has finished
- close closes all resources init created?
Also, as it not so straight forward to get why it's calling Do with an empty function, I believe it would be good to add a comment here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! 🙇
The goal here is to avoid there are goroutines leaking after close has been called (which can happen if init hasn't finished).
Those are good points, added a comment and updated the code 👍
Proposed commit message
prevent goroutine leak and wait for init to complete when closing the processor
Checklist
stresstest.shscript to run them under stress conditions and race detector to verify their stability../changelog/fragmentsusing the changelog tool.Disruptive User Impact
Author's Checklist
How to test this PR locally
Related issues
panic: Log in goroutine after TestGenerateProcessorList has completed#47528Use cases
Screenshots
Logs