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

fix SIGTERM support to stop/kill stack #11127

Merged
merged 1 commit into from
Oct 26, 2023
Merged

Conversation

ndeloof
Copy link
Contributor

@ndeloof ndeloof commented Oct 24, 2023

What I did
this fix signal management:

A dedicated goroutine is set to handle signal and trigger stop/kill commands (first signal will stop, the next one kills).
doneCh is set to stop this goroutine when no sigterm signal is caught. It's not actually used as a channel, just as a way for select to react as channel is closed and stop the goroutine
isTerminated boolean let us know stack was terminated and doneCh doesn't need to be closed. It is set once stop succeed, so that it in the meantime we can capture subsequent SIGTERM and kill the stack.

Note: this works well when ran by ~/.docker/cli-plugins/docker-compose up or com.docker.cli compose up but when used with cloud integrations which forwards signals (😓) we receive duplicated SIGTERM signals and go runtime kills compose plugin after 3rd one

Related issue
closes #11123

(not mandatory) A picture of a cute animal, if possible in relation to what you did

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
@ndeloof ndeloof requested review from a team, nicksieger, StefanScherer, ulyssessouza, glours, milas and laurazard and removed request for a team October 24, 2023 16:32
@codecov
Copy link

codecov bot commented Oct 24, 2023

Codecov Report

Attention: 12 lines in your changes are missing coverage. Please review.

Comparison is base (6ab41d6) 57.54% compared to head (b02ce6c) 57.39%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11127      +/-   ##
==========================================
- Coverage   57.54%   57.39%   -0.15%     
==========================================
  Files         129      129              
  Lines       11272    11285      +13     
==========================================
- Hits         6486     6477       -9     
- Misses       4156     4177      +21     
- Partials      630      631       +1     
Files Coverage Δ
cmd/compose/compose.go 70.84% <100.00%> (+0.15%) ⬆️
pkg/compose/publish.go 0.00% <0.00%> (ø)
pkg/compose/up.go 80.21% <82.97%> (-3.12%) ⬇️

... and 3 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@glours glours left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ndeloof ndeloof merged commit dd0803d into docker:main Oct 26, 2023
24 checks passed
@ndeloof ndeloof deleted the fix_sigint branch October 26, 2023 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] CTRL+C No longer force kills processes
2 participants