Skip to content
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

Add signal handling to context #2505

Closed
phillebaba opened this issue May 14, 2024 · 0 comments · Fixed by #2567
Closed

Add signal handling to context #2505

phillebaba opened this issue May 14, 2024 · 0 comments · Fixed by #2567
Labels
enhancement ✨ New feature or request

Comments

@phillebaba
Copy link
Collaborator

Is your feature request related to a problem? Please describe.

Context usage is being introduced in #2405 which is great. When this is done it is going to be possible to cancel contexts also. In the Zarf CLI currently if a user presses Ctrl+C the process will be killed immediately without having the opportunity to cancel the context. Which leaves in flight requests abandoned.

Describe the solution you'd like

  • Given A running CLI process
  • When An interrupt signal occurs
  • Then All contexts should be cancelled

Describe alternatives you've considered

I am not sure if this is a thing people do when building CLIs using Cobra. The alternative solution is to not handle any interrupt signals at all.

Additional context

N/A

@phillebaba phillebaba added the enhancement ✨ New feature or request label May 14, 2024
AustinAbro321 added a commit that referenced this issue Jun 3, 2024
## Description

Right now different functions handle interrupts in different ways. Some
will register their own signal listeners while others will use the
global signal handler that exits the program. This means that contexts
are never cancelled giving the process time to shut down and clean up.
This change adds a signal handler to the Cobra parent context and
removes the other signal handlers. Now all commands will use the same
signal handler.

## Related Issue

Fixes #2505 
Relates to #2520 

## Checklist before merging

- [x] Test, docs, adr added or updated as needed
- [x] [Contributor Guide
Steps](https://github.com/defenseunicorns/zarf/blob/main/.github/CONTRIBUTING.md#developer-workflow)
followed

Co-authored-by: Austin Abro <37223396+AustinAbro321@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant