Skip to content

explicitly handle SIGINT and SIGTERM#1448

Merged
openshift-merge-bot[bot] merged 1 commit into
operator-framework:masterfrom
joelanford:explicit-signal-handling
Sep 14, 2024
Merged

explicitly handle SIGINT and SIGTERM#1448
openshift-merge-bot[bot] merged 1 commit into
operator-framework:masterfrom
joelanford:explicit-signal-handling

Conversation

@joelanford

@joelanford joelanford commented Sep 10, 2024

Copy link
Copy Markdown
Member

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 run defer statements prior to exiting.

Reviewer Checklist

  • Implementation matches the proposed design, or proposal is updated to match implementation
  • Sufficient unit test coverage
  • Sufficient end-to-end test coverage
  • Docs updated or added to /docs
  • Commit messages sensible and descriptive

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 10, 2024
@openshift-ci

openshift-ci Bot commented Sep 10, 2024

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 10, 2024
@codecov

codecov Bot commented Sep 10, 2024

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 48.53%. Comparing base (1f9e725) to head (6a917e9).
Report is 15 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

@joelanford joelanford force-pushed the explicit-signal-handling branch 2 times, most recently from 7be452f to fdefe60 Compare September 11, 2024 18:05
@joelanford joelanford force-pushed the explicit-signal-handling branch from fdefe60 to 6a917e9 Compare September 11, 2024 21:03
@joelanford joelanford marked this pull request as ready for review September 11, 2024 21:10
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 11, 2024

@perdasilva perdasilva left a comment

Copy link
Copy Markdown
Contributor

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 ^^

@openshift-ci

openshift-ci Bot commented Sep 12, 2024

Copy link
Copy Markdown
Contributor

[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

Details Needs approval from an approver in each of these files:
  • OWNERS [joelanford,perdasilva]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@grokspawn

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Sep 14, 2024
@openshift-merge-bot openshift-merge-bot Bot merged commit 66733c7 into operator-framework:master Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants