Skip to content
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

Cherry-pick #19567 to 7.x: [Elastic Agent] Properly stop subprocess when receiving SIGTERM #19683

Merged
merged 1 commit into from
Jul 7, 2020

Conversation

blakerouse
Copy link
Contributor

Cherry-pick of PR #19567 to 7.x branch. Original message:

What does this PR do?

Fixes issue where if Elastic Agent is stopped the spawned subprocesses are not stopped. This ensures that on SIGTERM to Elastic Agent that it properly shutdowns the subprocesses, by sending the ExpectedState_Stopping over GRPC and waiting for the process to stop (kill it after 30 seconds, if it doesn't stop).

On Linux in the case that Elastic Agent is kill -9 all its spawned subprocesses will also be kill -9, without having to worry that any children processes are still handing around. Something that Windows or Mac does not support.

Why is it important?

So subprocess are not orphaned when Elastic Agent is stopped or killed.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • [] 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
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Related issues

Logs

2020-07-01T15:24:09-04:00 INFO  app.go:160      Signaling application to stop because of shutdown: metricbeat(metricbeat--8.0.0-SNAPSHOT--36643631373035623733363936343635)
2020-07-01T15:24:09-04:00 INFO  reporter.go:51  2020-07-01T15:24:09-04:00: type: 'STATE': sub_type: 'STOPPED' message: Application: filebeat--8.0.0-SNAPSHOT--36643631373035623733363936343635[a2c055bc-831f-48dd-9204-075f88cd5760]: State changed to STOPPED: Stopped
2020-07-01T15:24:09-04:00 INFO  app.go:160      Signaling application to stop because of shutdown: metricbeat(metricbeat--8.0.0-SNAPSHOT)
2020-07-01T15:24:09-04:00 INFO  reporter.go:51  2020-07-01T15:24:09-04:00: type: 'STATE': sub_type: 'STOPPED' message: Application: metricbeat--8.0.0-SNAPSHOT--36643631373035623733363936343635[a2c055bc-831f-48dd-9204-075f88cd5760]: State changed to STOPPED: Stopped
2020-07-01T15:24:12-04:00 INFO  reporter.go:51  2020-07-01T15:24:12-04:00: type: 'STATE': sub_type: 'STOPPED' message: Application: metricbeat--8.0.0-SNAPSHOT[a2c055bc-831f-48dd-9204-075f88cd5760]: State changed to STOPPED: Stopped

…tic#19567)

* Implement proper shutdown so spawned subprocesses are stopped correctly when Elastic Agent is signalled to stop.

* Swap shutdown order for fleet mode.

* Reorder stop in local_mode. Add to changelog.

(cherry picked from commit a820842)
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jul 6, 2020
@blakerouse blakerouse self-assigned this Jul 6, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/ingest-management (Team:Ingest Management)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jul 6, 2020
@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #19683 opened]

  • Start Time: 2020-07-06T18:05:42.522+0000

  • Duration: 32 min 49 sec

Copy link
Contributor

@michalpristas michalpristas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@michalpristas michalpristas merged commit 2be60b2 into elastic:7.x Jul 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants