[cmd/opampsupervisor] Fix memory leak and enable goleak #30496
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 aStop
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 abreak
statement has been changed toreturn
. Thebreak
statement was only breaking out of theselect
statement, but since it's nested within afor
loop, the loop just kept going instead of completing successfully.This also enables
goleak
checks forcmd/opampsupervisor
andcmd/opampsupervisor/supervisor
packagesLink to tracking Issue:
#30438
Testing:
Existing tests and new
goleak
checks are passing.