-
Notifications
You must be signed in to change notification settings - Fork 248
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
explicitly handle SIGINT and SIGTERM #1448
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
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.
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
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm |
66733c7
into
operator-framework:master
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
defer
statements are not executed when these signals are not caught and handled by the program. This PR ensures that we rundefer
statements prior to exiting.Reviewer Checklist
/docs