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

Abrupt shutdown not properly handled #727

Closed
feelingsonice opened this issue Sep 6, 2024 · 6 comments
Closed

Abrupt shutdown not properly handled #727

feelingsonice opened this issue Sep 6, 2024 · 6 comments
Labels
duplicate This issue or pull request already exists question Further information is requested

Comments

@feelingsonice
Copy link

Run a container through this crate and abruptly shut it down with something like ctrl+c, and the containers would still be running. This leaves docker in an invalid state and either have consequences on subsequent runs or leaves a bunch of dangling containers.

Personally for me, a huge pain of testing with docker is state management. If I programmatically spin up docker containers via invoked system commands, I have to manage its state, figure out if it's actually started, free the ports, shut it down etc. This is just all not worth it for me.

The cornucopia crate, for example, uses the postgres docker to validate SQL schemas and generate sql queries at compile time, and it does this via docker containers created via std::process commands, and its auto-build feature is literally broken right now because it doesn't fully manage the state of the docker containers it created.

testcontainers solves a huge part of this problem for me but I was disappointed to see that it didn't shutdown the containers when w/e program abruptly stopped. It would be really nice if it could at least do a best effort try when this happened :)

@DDtKey
Copy link
Collaborator

DDtKey commented Sep 6, 2024

Hi 👋

Have you tried watchdog feature? It's not comprehensive at the moment, but handles signals and stops containers.

But in general it's known issue and will be covered with #577 (which is high-priority task for us, but any contributions are welcome)

@feelingsonice
Copy link
Author

No idea it existed, how do I used it?

@DDtKey
Copy link
Collaborator

DDtKey commented Sep 6, 2024

Just enable the feature for testcontainers dependency

@DDtKey DDtKey added duplicate This issue or pull request already exists question Further information is requested labels Sep 24, 2024
@DDtKey
Copy link
Collaborator

DDtKey commented Sep 24, 2024

I’m going to close this issue as is known and should be solved by #577
I hope you don’t mind

@DDtKey DDtKey closed this as completed Sep 24, 2024
@DDtKey DDtKey closed this as not planned Won't fix, can't repro, duplicate, stale Sep 24, 2024
@feelingsonice
Copy link
Author

Hmm interesting, it worked. Curious how this is different from what I have. I thought that drop is called for static vars when the program terminates?

@DDtKey
Copy link
Collaborator

DDtKey commented Oct 1, 2024

I guess you answered in the wrong issue.

No, drop isn't called for static variables. See my answer in the relevant issue and check the conversations in other similar ones

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants