elastic / elastic/elastic-agent
[Bug] Prevent supervised collector health-check port handoff conflicts
- Dominant language
- Go
- Stars
- 275
- Forks
- 264
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 312
Description
- Version: 9.4.2 and current `main`
- Operating System: Linux; the handoff is platform-independent
- Discuss Forum URL: N/A — confirmed from diagnostics and source analysis
- Steps to Reproduce:
1. Start a supervised OTel collector without a fixed health-check endpoint.
2. Make the port selected by `findRandomTCPPorts` unavailable after its temporary listener closes but before the collector binds it.
3. Observe `healthcheckv2` fail with `address already in use` and the collector shut down.
## Expected behavior
A port selected as available should remain usable by the collector, or startup should select another port after a bind conflict.
## Actual behavior
`findRandomTCPPorts` closes its temporary listener before `process.Start` launches the collector. Another listener can claim the port during that handoff, causing the managed `healthcheckv2` extension to fail and terminate the collector.
## Additional context
Random per-start selection was introduced in #10240. The existing recovery loop may select another port after process failure, but it does not make the initial handoff atomic.
Contributor guide
Research direction
Trace findRandomTCPPorts through process.Start and the managed healthcheckv2 startup path, focusing on the gap after the temporary listener closes. Reproduce the port handoff race and inspect the existing recovery loop. Done means startup avoids the initial bind conflict or retries safely without shutting down the supervised collector.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100