-
-
Notifications
You must be signed in to change notification settings - Fork 290
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
[Bug]: Containers are not cleaned-up with DisposeAsync when Resource Reaper is disabled #783
Comments
I agree, this is a bit unfortunate. I must admit that I did not have something like Bitbucket in mind when I made the change. I will try to add more information, and perhaps we can come up with a better implementation. Disabling Ryuk is not recommended, as it is the only reliable way to clean up the environment. This is not a significant issue on ephemeral CI, but I am not very familiar with the Bitbucket CI environment. Is it ephemeral? If not, it can get messy. @eddumelendez @kiview do you know how Java does the "clean up" on Bitbucket? I would assume there is no clean up either, right? |
@HofmeisterAn I've not investigated, though I suspect the Bitbucket CI environment is ephemeral. There's support for docker build image caching, though I suspect containers don't last long. Containers would soon pile up if they didn't clean up somehow. I'll investigate further, I could add a check and only disable Ryuk in the CI. Though I'd advocate a belt-and-braces approach, by allowing for explicit clean-up were possible and using Ryuk as a fallback. |
I think we can assign a Resource Reappear session ID to each resource, which is essentially the same as |
Of course, happy to test a fix. Just let me know. |
I've prepared a fix in #783 ( |
@HofmeisterAn I've just seen your reply and tested it against the latest Here is the updated (slightly simplified) xunit test fixture public class EventStoreContainerFixture : IAsyncLifetime
{
private IContainer _eventStoreContainer;
public EventStoreContainerFixture()
{
HostPort = 2113;
ConnectionString = $"esdb://admin:changeit@localhost:{HostPort}?tls=false";
// We get the following error in BitBucket pipelines. Setting ResourceReaperEnabled to false fixes it.
// {"message":"authorization denied by plugin pipelines: --mounts is not allowed"}
// See: https://github.com/testcontainers/testcontainers-dotnet/issues/492#issuecomment-1167174986
TestcontainersSettings.ResourceReaperEnabled = false;
_eventStoreContainer = new ContainerBuilder()
.WithImage("eventstore/eventstore:20.10.5-bionic")
.WithCommand("--insecure")
.WithCommand("--enable-external-tcp")
.WithPortBinding(HostPort, 2113)
.WithWaitStrategy(Wait.ForUnixContainer().UntilPortIsAvailable(2113))
.Build();
}
public int HostPort { get; }
public string ConnectionString { get; }
public Task InitializeAsync()
{
return _eventStoreContainer.StartAsync();
}
public Task DisposeAsync()
{
return _eventStoreContainer.DisposeAsync();
}
} |
I would like to point out once again that disabling the Resource Reaper is not recommended. However, in your case, running on BitBucket, there may be no other option. Therefore, I suggest that you set the TESTCONTAINERS_RYUK_DISABLED environment variable in your CI and do not touch the development configurations. |
Duly noted, thank you. |
Testcontainers version
2.4.0
Using the latest Testcontainers version?
Yes
Host OS
Windows (WSL2)
Host arch
x64
.NET version
7.0.102
Docker version
Docker info
What happened?
Our CI uses BitBucket pipelines, and following the instructions here, I disabled Resource Reaper.
Sometime later, I discovered the containers were not being cleaned up, and after further investigation, I started calling
CleanUpAsync()
before callingDisposeAsync()
.I upgraded to 2.4.0 today and started following the obsolete warnings (we treat warnings as errors), and I removed
CleanUpAsync()
as it has been marked as obsolete. If I upgrade toIContainer
, it has noCleanUpAsync()
method.I have again discovered that containers are not cleaned up when calling
DisposeAsync()
.So I'm stuck in a bind.
CleanUpAsync()
.None of the options is ideal. I'm going for option 4 for now.
Relevant log output
No response
Additional information
Here is our (slightly simplified) xunit test fixture
The text was updated successfully, but these errors were encountered: