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 #11710: Avoid to try to close channel twice after hitting Ctrl-C on compose up #11719

Merged
merged 5 commits into from
Apr 20, 2024

Conversation

jsoriano
Copy link
Contributor

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 start will 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 start has finished.

Apart of that I am doing some other changes around there:

  • Use atomic.Bool for isTerminated. Not sure if really needed, but looks safer, as it is a value that is written and read from different goroutines.
  • Cleanup of signal handling, what can be useful if Up is called as part of other commands.
  • Use context.WithoutCancel(ctx) in the cases where context.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.

Signed-off-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
Signed-off-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
@jsoriano
Copy link
Contributor Author

@ndeloof is there anything pending to merge this PR?

@ndeloof ndeloof enabled auto-merge (rebase) April 18, 2024 09:31
auto-merge was automatically disabled April 18, 2024 09:38

Rebase failed

@ndeloof
Copy link
Contributor

ndeloof commented Apr 19, 2024

Please rebase your branch then we can merge

@ndeloof ndeloof enabled auto-merge (squash) April 20, 2024 06:02
@ndeloof ndeloof merged commit 5682480 into docker:main Apr 20, 2024
27 checks passed
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>
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] Channel double close panic on Ctrl-C during up
2 participants