explicitly handle SIGINT and SIGTERM#1448
Conversation
|
Skipping CI for Draft Pull Request. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1448 +/- ##
==========================================
+ Coverage 48.47% 48.53% +0.05%
==========================================
Files 136 135 -1
Lines 12814 12800 -14
==========================================
Hits 6212 6212
+ Misses 5561 5547 -14
Partials 1041 1041 ☔ View full report in Codecov by Sentry. |
7be452f to
fdefe60
Compare
fdefe60 to
6a917e9
Compare
perdasilva
left a comment
There was a problem hiding this comment.
If I understand the changes correctly, we are now using the signal package to create a top context that will cancel on SIGINT or SIGTERM. This context is set as the cmd context, and each (long running) opm command creates a sub-context (with the top level context as parent) for its work. These commands also spawn a go routine to monitor the context and shutdown gracefully if it gets cancelled. Therefore, if the command's context gets cancelled -> graceful shutdown, if the process gets a SIGINT or SIGTERM, the top level process gets cancelled and propagates down to the sub-contexts -> graceful shutdown.
We're getting a breaking api change by deleting shutdown.go - but that should be ok as this package is only really meaningful for the command structure (as opposed to manipulating catalog content). So, lgtm ^^
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: joelanford, perdasilva The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/lgtm |
Description of the change:
This PR adds explicit handling for SIGINT and SIGTERM, so that we can catch those signals and propagate them via a Go context to long running processes in order to perform a graceful shutdown.
Motivation for the change:
Temporary files are being left behind because
deferstatements are not executed when these signals are not caught and handled by the program. This PR ensures that we rundeferstatements prior to exiting.Reviewer Checklist
/docs