Fix DatadogMonitor metrics forwarder goroutine leak on CR deletion#2805
Closed
majiayu000 wants to merge 1 commit intoDataDog:mainfrom
Closed
Fix DatadogMonitor metrics forwarder goroutine leak on CR deletion#2805majiayu000 wants to merge 1 commit intoDataDog:mainfrom
majiayu000 wants to merge 1 commit intoDataDog:mainfrom
Conversation
Add r.forwarders.Unregister(dm) call in finalizeDatadogMonitor() to stop the metrics forwarder goroutine when a DatadogMonitor CR is deleted. Without this, the forwarder goroutine leaks since its stopChan is never closed. This mirrors the existing pattern in DatadogAgent's finalizeDadV2(). The Unregister call is placed before deleteMonitor() to ensure the forwarder is always cleaned up, even if deleteMonitor() returns early on error. Fixes DataDog#2803 Signed-off-by: majiayu000 <1835304752@qq.com>
Member
|
Thank you for the contribution, I was working on the same issue at the same time unfortunately! Closing in favour of #2804 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
r.forwarders.Unregister(dm)call infinalizeDatadogMonitor()to stop the metrics forwarder goroutine when a DatadogMonitor CR is deletedr.operatorMetricsEnabledcheck, matching the existing pattern infinalizeDadV2()for the DatadogAgent controllerdeleteMonitor()to ensure cleanup happens even ifdeleteMonitor()returns early on errorFixes #2803
Test plan
Test_handleFinalizertests pass (deletion case usesoperatorMetricsEnabled=falseby default)go vet ./...passesgo build ./internal/controller/datadogmonitor/...passes