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

create task engine and run termination handler goroutine before warm pools polling #3078

Merged
merged 1 commit into from
Nov 4, 2021

Conversation

lydiafilipe
Copy link
Contributor

Summary

In this change, the termination handler goroutine is started before polling for instance target lifecycle state begins.
The windows process expects the termination handler to be invoked before it waits on the agent executing. Currently, since the termination handler is not being invoked when polling occurs, the process will not wait at all and exit after about a minute.
With this change, the goroutine for the termination handler will be started sooner.

Implementation details

The termination handler goroutine is moved out of startAsyncRoutines to start before the warm pools polling. Since the handler needs the task engine created, the task engine is now created before polling, however will still be initialized at a later point.

Testing

  • make test on both linux and windows
  • ran and stopped agent on both windows and linux, both with warm pools check enabled and not enabled. Checked that logs contained expected messaging.
    Linux (warm pools check enabled):
level=info time=2021-11-03T21:49:42Z msg="Agent received termination signal: terminated" module=termination_handler.go
level=debug time=2021-11-03T21:49:42Z msg="Shutting down task engine for final save" module=termination_handler.go
level=debug time=2021-11-03T21:49:42Z msg="Saving state before shutting down" module=termination_handler.go
level=info time=2021-11-03T21:49:42Z msg="Event stream ContainerChange stopped listening..." module=eventstream.go

Windows (warm pools check enabled):

level=info time=2021-11-03T21:45:33Z msg="Stopping Windows service" module=agent_windows.go
level=info time=2021-11-03T21:45:33Z msg="Received normal signal from Windows to exit" module=agent_windows.go
level=info time=2021-11-03T21:45:33Z msg="Termination handler received signal to stop" module=agent_windows.go
level=debug time=2021-11-03T21:45:33Z msg="Shutting down task engine for final save" module=termination_handler.go
level=debug time=2021-11-03T21:45:33Z msg="Saving state before shutting down" module=termination_handler.go
level=info time=2021-11-03T21:45:33Z msg="Bye Bye! Exiting with 0" module=agent_windows.go

New tests cover the changes: yes

Description for the changelog

Run termination handler goroutine before warm pools polling

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@lydiafilipe lydiafilipe merged commit f613ddd into aws:feature/warm_pools Nov 4, 2021
lydiafilipe added a commit to lydiafilipe/amazon-ecs-agent that referenced this pull request Nov 17, 2021
@lydiafilipe lydiafilipe mentioned this pull request Feb 2, 2022
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.

4 participants