Skip to content
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

[cmd/opampsupervisor] Fix memory leak and enable goleak #30496

Merged
merged 5 commits into from
Jan 29, 2024

Conversation

crobert-1
Copy link
Member

@crobert-1 crobert-1 commented Jan 12, 2024

Description:

NewSupervisor starts two goroutines, one for the health check ticker and another running the agent process. Each was causing a leak. To resolve the health check ticker goroutine leak a Stop call has been added to it during shutdown. To resolve the agent process leak a wait group has been added (to make sure shutdown blocks until the agent process is completely shutdown), and a break statement has been changed to return. The break statement was only breaking out of the select statement, but since it's nested within a for loop, the loop just kept going instead of completing successfully.

This also enables goleak checks for cmd/opampsupervisor and cmd/opampsupervisor/supervisor packages

Link to tracking Issue:
#30438

Testing:
Existing tests and new goleak checks are passing.

@crobert-1 crobert-1 changed the title [cmd/opampsupervisor] Enable goleak [chore][cmd/opampsupervisor] Enable goleak Jan 12, 2024
@crobert-1 crobert-1 changed the title [chore][cmd/opampsupervisor] Enable goleak [cmd/opampsupervisor] Fix memory leak and enable goleak Jan 16, 2024
@crobert-1 crobert-1 marked this pull request as ready for review January 16, 2024 20:32
@crobert-1 crobert-1 requested a review from a team January 16, 2024 20:32
Copy link
Contributor

@evan-bradley evan-bradley left a comment

Choose a reason for hiding this comment

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

Nice catches! Thank you.

@evan-bradley
Copy link
Contributor

Thanks for your patience with the review. Could you rebase on main?

@crobert-1
Copy link
Member Author

Thanks for your patience with the review. Could you rebase on main?

Done 👍

@evan-bradley evan-bradley merged commit 5a3a3ea into open-telemetry:main Jan 29, 2024
85 checks passed
@github-actions github-actions bot added this to the next release milestone Jan 29, 2024
cparkins pushed a commit to AmadeusITGroup/opentelemetry-collector-contrib that referenced this pull request Feb 1, 2024
…ry#30496)

**Description:** <Describe what has changed.>
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->

`NewSupervisor` starts two goroutines, one for the health check ticker
and another running the agent process. Each was causing a leak. To
resolve the health check ticker goroutine leak a `Stop` call has been
added to it during shutdown. To resolve the agent process leak a wait
group has been added (to make sure shutdown blocks until the agent
process is completely shutdown), and a `break` statement has been
changed to `return`. The `break` statement was only breaking out of the
`select` statement, but since it's nested within a `for` loop, the loop
just kept going instead of completing successfully.


This also enables `goleak` checks for `cmd/opampsupervisor` and
`cmd/opampsupervisor/supervisor` packages

**Link to tracking Issue:** <Issue number if applicable>
open-telemetry#30438

**Testing:** <Describe what testing was performed and which tests were
added.>
Existing tests and new `goleak` checks are passing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants