fix: ensure EDOT subprocess shuts down gracefully on agent termination#9886
Merged
pkoutsovasilis merged 6 commits intoelastic:mainfrom Sep 16, 2025
Conversation
0194d5f to
e114ea5
Compare
e114ea5 to
455fd59
Compare
Contributor
|
Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane) |
pchila
reviewed
Sep 12, 2025
Member
pchila
left a comment
There was a problem hiding this comment.
A couple of nitpicks and a question on the select statement
swiatekm
previously approved these changes
Sep 12, 2025
Member
swiatekm
left a comment
There was a problem hiding this comment.
LGTM, some minor nitpicks and a non-blocking question.
cmacknz
reviewed
Sep 12, 2025
c997949
|
Contributor
💛 Build succeeded, but was flaky
Failed CI StepsHistory
|
Member
|
LGTM, @swiatekm can do the approving here since he still has unresolved comments. |
swiatekm
approved these changes
Sep 16, 2025
mergify bot
pushed a commit
that referenced
this pull request
Sep 16, 2025
#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)
pkoutsovasilis
added a commit
that referenced
this pull request
Sep 16, 2025
#9886) (#9986) * 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) Co-authored-by: Panos Koutsovasilis <panos.koutsovasilis@elastic.co>
v1v
added a commit
that referenced
this pull request
Sep 16, 2025
* upstream: (26 commits) fix: ensure EDOT subprocess shuts down gracefully on agent termination (#9886) [main][Automation] Update versions (#9976) Add Collector reference docs and automation (#9953) [beatreceivers] Integrate beatsauthextension (#9257) [main][Automation] Update versions (#9941) Update OTel components to v0.132.0/v1.38.0 (#9954) Enhancement/5235 wrap errors when marking upgrade (#9366) Mount Go build cache into crossbuild container (#9094) Liveness agent state (#9673) [main][Automation] Bump VM Image version to 1757725254 (#9942) Enhancement/5235 correctly wrap errors from copyActionDir and copyRunDirectory (#9349) [main][Automation] Update elastic/beats to afc53c0479ac (#9874) Add -coverpkg option when running unit test to calculate coverage across packages (#9913) Cache binaries downloaded for packaging locally (#9133) [main][Automation] Update versions (#9897) Disable flaky test TestBeatsReceiverLogs (#9891) Allow overriding AGENT_PACKAGE_VERSION and MANIFEST_URL when USE_PACKAGE_VERSION=true (#9864) add ingest-docs team as CODEOWNERS for release notes and docset.yml (#9865) fix: correct spelling of 'output' in various templates and monitoring code (#9827) k8s: Add comment around hostUsers for Universal Profiling deployments (#9847) ...
intxgo
pushed a commit
to intxgo/elastic-agent
that referenced
this pull request
Sep 24, 2025
elastic#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
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