Merged
Conversation
Currently, Shutdown requests forcefully exits the binary without cleaning up resources and IO channels, or flushing logs. Added `.Done()` and `.IsShutdown()` methods to service watch for service shutdown requests from containerd, and appropriately close background servers and go routines. Added `NewService` method and creation options to properly initialize the `service` struct. Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
jterry75
reviewed
Feb 2, 2022
Contributor
jterry75
left a comment
There was a problem hiding this comment.
This is a great change. Thanks
jterry75
reviewed
Feb 2, 2022
ttrp.Shutdown( has a 200ms ticker, not a timeout. Adding a proper timeout in case shutdown takes too long. Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
Contributor
|
Looks good! |
dcantah
reviewed
Feb 3, 2022
dcantah
reviewed
Feb 3, 2022
dcantah
reviewed
Feb 3, 2022
dcantah
reviewed
Feb 3, 2022
Checking return value of `shutdownInternal` for cleanup in service tests. Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
ambarve
reviewed
Feb 3, 2022
ambarve
reviewed
Feb 3, 2022
dcantah
approved these changes
Feb 4, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, when a
Shutdownrequest is received,servicecallsos.Exitto forcefully exits the binary without cleaning up resources and IO channels, ending spans, or flushing logs. Primarily this prevents logging of shim-wide or long running spans but can also leak un-closed system resources.For reference, the runc shim within containerd does not respect the
ShutdownRequest.Nowparameter, and calls several cleanup callbacks instead of exiting immediately viaos.ExitAdded
.Done()and.IsShutdown()methods toserviceto signal that a service shutdown request from containerd for the init task was received, and updated theserveaction to wait on a shutdown request to close the ttrpc servers and pipes.Added
NewServicemethod and creation options to properly initialize theservicestruct, namely to create the internal channel to signal shutdown.Added tests for
shutdownInternal.Signed-off-by: Hamza El-Saawy hamzaelsaawy@microsoft.com