-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Elastic Agent] Await execution finish on windows #27730
Conversation
Pinging @elastic/agent (Team:Agent) |
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
Trends 🧪💚 Flaky test reportTests succeeded. Expand to view the summary
Test stats 🧪
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Looks good.
* Await execution finish on windows * don't wait if not running as a service (cherry picked from commit 2f897aa)
* Await execution finish on windows * don't wait if not running as a service (cherry picked from commit 2f897aa)
We attempted to validate above PR on 7.15.0-snapshot on windows 10 machine and found it fixed now.
Build details: Thanks |
* Await execution finish on windows * don't wait if not running as a service
What does this PR do?
The problem is described in issue: #27527
When user wants to stop the service using service manager, error is returned about unexpected termination and agent is restarted.
Reason for this is that agent won't send
stopped
state to service manager before termination.In our codebase we use
NotifyTermination
provided by libbeat on exit. This closes channel and exits the state loop running in a separate goroutine which then should send thestopped
state to service manager.The problem is when we exit right after this call and too quickly. In this case goroutine wont reach the point where
stopped
is sent and service manager gets the impression we crashed.To fix this we just need to make sure that
svc.Run
inlibbeat/service/service_windows.go
is finished before exiting. Usually it just takes few milliseconds to finish the process but 500 millisecond limit is there to prevent process getting stuck in case something goes wrong.Why is it important?
Fixes: #27527
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.