elastic / elastic/elastic-agent
Install signal handlers earlier in the startup process
- Dominant language
- Go
- Stars
- 275
- Forks
- 264
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 303
Description
Right now, signal handlers are [installed](https://github.com/elastic/elastic-agent/blob/68e52d042cc28481ab2e882c85f41e3132d6f7b5/internal/pkg/agent/cmd/run.go#L497) asynchronously relative to the coordinator, after all the other setup. If Elastic Agent gets a signal during startup, it'll be terminated ungracefully. The handlers should be as early in the startup process as possible.
The best way to do it is probably to use a context and refactor startup to handle it gracefully.
This caused a test to be flaky here: https://github.com/elastic/elastic-agent/pull/14150. Turns out agent logging `Elastic Agent started` does not mean signal handlers are registered.
Contributor guide
Research direction
Start in internal/pkg/agent/cmd/run.go around the signal-handler installation at line 497, then review the startup flow relative to the coordinator. Use the flaky test context from pull request #14150 to check behavior when a signal arrives during startup. Done means handlers are registered earlier and startup termination is handled gracefully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100