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

Ignore stopped containers in resource leak detector #21280

Merged

Conversation

nineinchnick
Copy link
Member

Description

Stopped containers can be left behind when using
withStartupAttempts(). They should only use up disk space, not other resources, and will still be cleaned up by testcontainers on exit.

Additional context and related issues

Release notes

(x) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text:

Stopped containers can be left behind when using
`withStartupAttempts()`. They should only use up disk space, not other
resources, and will still be cleaned up by testcontainers on exit.
@nineinchnick
Copy link
Member Author

@wendigo would you like to take a look too?

@kokosing kokosing merged commit d511fd6 into trinodb:master Mar 28, 2024
90 of 91 checks passed
@nineinchnick nineinchnick deleted the report-leaked-containers-without-stopped branch March 28, 2024 15:07
@github-actions github-actions bot added this to the 444 milestone Mar 28, 2024
@@ -81,6 +81,8 @@ public void testPlanExecutionFinished(TestPlan testPlan)

List<Container> containers = dockerClient.listContainersCmd()
.withLabelFilter(Map.of(DockerClientFactory.TESTCONTAINERS_SESSION_ID_LABEL, DockerClientFactory.SESSION_ID))
// ignore status "exited" - for example, failed containers after using `withStartupAttempts()`
.withStatusFilter(List.of("created", "restarting", "running", "paused"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why isn't "starting" on the list?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The set of status can change in the future, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, although I'm not sure how likely is that. This list hasn't changed at least since 8 years: docker-java/docker-java@acfe65d

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Java API javadoc may or may not be up to date. It's not the source of truth for docker container statuses.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, do you have a better reference?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, but also i didn't write this code :)

ssheikin added a commit to ssheikin/testcontainers-java that referenced this pull request Oct 30, 2024
reportLeakedContainers adapted from
trinodb/trino#20297
trinodb/trino#21280

Co-authored-by: Piotr Findeisen <[email protected]>
Co-authored-by: Jan Waś <[email protected]>
ssheikin added a commit to ssheikin/testcontainers-java that referenced this pull request Oct 31, 2024
reportLeakedContainers adapted from
trinodb/trino#20297
trinodb/trino#21280

Co-authored-by: Piotr Findeisen <[email protected]>
Co-authored-by: Jan Waś <[email protected]>
ssheikin added a commit to ssheikin/testcontainers-java that referenced this pull request Nov 5, 2024
reportLeakedContainers adapted from
trinodb/trino#20297
trinodb/trino#21280

Co-authored-by: Piotr Findeisen <[email protected]>
Co-authored-by: Jan Waś <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants