-
Notifications
You must be signed in to change notification settings - Fork 259
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
Shutdown hcsshim properly #1289
Merged
Merged
Conversation
This file contains 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
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
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.
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>
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
ambarve
approved these changes
Feb 4, 2022
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
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
Shutdown
request is received,service
callsos.Exit
to 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.Now
parameter, and calls several cleanup callbacks instead of exiting immediately viaos.Exit
Added
.Done()
and.IsShutdown()
methods toservice
to signal that a service shutdown request from containerd for the init task was received, and updated theserve
action to wait on a shutdown request to close the ttrpc servers and pipes.Added
NewService
method and creation options to properly initialize theservice
struct, namely to create the internal channel to signal shutdown.Added tests for
shutdownInternal
.Signed-off-by: Hamza El-Saawy hamzaelsaawy@microsoft.com