Fix #11710: Avoid to try to close channel twice after hitting Ctrl-C on compose up#11719
Merged
ndeloof merged 5 commits intodocker:mainfrom Apr 20, 2024
Merged
Fix #11710: Avoid to try to close channel twice after hitting Ctrl-C on compose up#11719ndeloof merged 5 commits intodocker:mainfrom
ndeloof merged 5 commits intodocker:mainfrom
Conversation
Signed-off-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
Signed-off-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
ndeloof
approved these changes
Apr 15, 2024
Contributor
Author
|
@ndeloof is there anything pending to merge this PR? |
auto-merge was automatically disabled
April 18, 2024 09:38
Rebase failed
Contributor
|
Please rebase your branch then we can merge |
temenuzhka-thede
pushed a commit
to temenuzhka-thede/compose
that referenced
this pull request
Sep 17, 2024
…trl-C on compose up (docker#11719) Ensure done channel is closed only once Signed-off-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What I did
Try to fix a panic happening when hitting Ctrl-C on docker compose up. I could barely reproduce the issue, so not sure if this change fixes it, but I think that at least it can improve the situation.
I think that the channel should not be closed in the graceful termination. If it successfully stops the containers, then
startwill also finish and the channel can be closed then. If the graceful termination fails to stop the containers and closes the channel, then it will close the channel, finalizing the goroutine and preventing further Ctrl-C to do anything.So I am removing the close in the graceful termination, and doing it in all cases once
starthas finished.Apart of that I am doing some other changes around there:
atomic.BoolforisTerminated. Not sure if really needed, but looks safer, as it is a value that is written and read from different goroutines.Upis called as part of other commands.context.WithoutCancel(ctx)in the cases wherecontext.Background()was being used. This way the rest of the context information is propagated.Happy to move these changes to different PRs if neccesary.
Related issue
Fixes #11710.