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

Allow to register shutdown hooks for containers terminated by Ryuk #148

Open
shelajev opened this issue Aug 9, 2024 · 2 comments
Open

Comments

@shelajev
Copy link
Member

shelajev commented Aug 9, 2024

Sometimes containers need to execute some shut down logic. In the code I can override a lifecycle method, something like containerIsStopping in Testcontainers-java for example and execute custom shutdown logic.

But if my containers are garbage collected by Ryuk, it's currently impossible (or very hard) to provide a shutdown logic.

I'd like to be able to register a shutdown hook for Ryuk, it can be as simple as enabling the behavior and Ryuk checking for a particular file path and running that file if exists before killing the container.

This will allow me:

  • enable shutdown hooks in Ryuk
  • copy the script with the shutdown logic into the container
  • override the containerIsStopping with calling the same file in the container

And my containers will clean up resources whether they are stopped by code or Ryuk.

@bsideup
Copy link
Member

bsideup commented Aug 9, 2024

Sometimes containers need to execute some shut down logic

Do you have examples?

But if my containers are garbage collected by Ryuk, it's currently impossible (or very hard) to provide a shutdown logic.

The idea is that Ryuk should kill containers, not gracefully stop them. Any graceful shutdown should be done explicitly in the tests. But maybe I am missing some valid use case?

@mdelapenya
Copy link
Member

@shelajev in tc-go there are PreTerminates and PostTerminate hooks, which are called in the Go test program. So if you are used to using ctr.Terminate(ctx) in your Go tests, then you benefit from using those hooks.

I agree with @bsideup here, as Ryuk is just the messenger 🤷

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

No branches or pull requests

3 participants