-
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] Add ability to re-exec agent #20111
Conversation
Pinging @elastic/ingest-management (Team:Ingest Management) |
💔 Tests FailedExpand to view the summary
Build stats
Test stats 🧪
Test errorsExpand to view the tests failures
--------------------- >> end captured stdout << ----------------------
Steps errorsExpand to view the steps failures
Log outputExpand to view the last 100 lines of log output
|
return errors.New(err, "failed to query service") | ||
} | ||
if status.State == svc.Stopped { | ||
err = service.Start() |
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.
do we need to handle case when service is set to auto-restart?
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.
It does handle this case, by checking the service.ProcessId
with the previous servicePid
. When the command is called the previous pid is sent in the arguments to the command. Inside the loop it checks if the service is stopped (if so it starts it, and exits) if its not stopped it checks the current service.ProcessId
against the previous pid and if it is different then it means it was already restarted so we also exit.
CI failures are unrelated to this PR. |
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.
LGTM
* Add ability to reexec on all platforms. * Get it working on Windows * Fix on mac. * Fix vet. * Update ShutdownChan to be receive only. (cherry picked from commit 5a37193)
* Add ability to reexec on all platforms. * Get it working on Windows * Fix on mac. * Fix vet. * Update ShutdownChan to be receive only.
What does this PR do?
This adds the ability to re-exec Elastic Agent in the same PID and memory address space (on unix) and with in the same service on Windows (not same PID and address space).
This has been tested on Windows using
SIGINT
and Windows services, but theSIGINT
catch is removed in the PR because it cannot be that way truly. Adding a way to perform this on Windows will occur in a follow up branch.Why is it important?
This is one of the steps to self-upgrading the Elastic Agent. This will also be used to allow reloading of the Elastic Agent when a configuration change that does not automatically get applied through the reloader.
Checklist
[ ] I have made corresponding changes to the documentation[ ] I have made corresponding change to the default configuration files[ ] I have added tests that prove my fix is effective or that my feature works(very hard to unit test)[ ] I have added an entry inCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Author's Checklist
SIGHUP
to process will perform shutdown of the application and the re-exec itself.How to test this PR locally
Start the
elastic-agent
then send SIGHUP.