[8.19] (backport #9886) fix: ensure EDOT subprocess shuts down gracefully on agent termination#9986
Merged
pkoutsovasilis merged 1 commit into8.19from Sep 16, 2025
Merged
Conversation
#9886) * fix: ensure EDOT subprocess shuts down gracefully on agent termination * fix: reword returned error * doc: add comment to describe the functionality of testing.go * fix: re-structure shutdown delay in test binary * fix: utilise t.SetEnv in unit-tests * feat: derive otel manager wait to stop timeout from agent.process.stop_timeout (cherry picked from commit 3e1fc2b)
Contributor
|
Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane) |
|
Contributor
💛 Build succeeded, but was flaky
Failed CI Steps |
pkoutsovasilis
approved these changes
Sep 16, 2025
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.




What does this PR do?
Ensures Elastic Agent gracefully shuts down the EDOT (collector) subprocess when the agent receives a terminating signal (e.g.,
SIGTERM) - i.e., when theOTelManagercontext is cancelled - instead of immediately killing it.Key changes:
collectorHandle.Stop(ctx context.Context)withStop(waitTime time.Duration)and honor it in both embedded and subprocess execution modes.waitTimeForStopto 30s (aligned with Beats subprocess defaults).updateChchannel buffered to a size of 1 and drain before write (pattern used elsewhere) to avoid shutdown/reconfig delays.TEST_SUPERVISED_COLLECTOR_DELAY.Why is it important?
Previously, on shutdown the agent could terminate in a way that kills EDOT immediately, risking incomplete cleanup of telemetry pipelines and leaving resources in a bad state. Waiting (up to 30s) for a graceful EDOT exit improves cleanup, stability, and hybrid agent resilience.
Checklist
./changelog/fragmentsusing the changelog toolDisruptive User Impact
No disruptive impact expected. The only behavior change is during shutdown: the agent now waits up to 30s for EDOT to exit gracefully before force-killing it. This improves stability and predictability for users..
How to test this PR locally
Related issues
N/A
This is an automatic backport of pull request #9886 done by Mergify.