-
-
Notifications
You must be signed in to change notification settings - Fork 439
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
chore: always close Docker client #939
chore: always close Docker client #939
Conversation
✅ Deploy Preview for testcontainers-go ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
I don't think adding my tests would help, I just added them to have a fast reproducible result. so LGTM from my side. As a side note: |
What does this PR do?
This PR improves how the Docker client is handled:
NegotiateAPIVersion(ctx)
method, it's passed as a client Opt when getting the new client.Close
method to the DockerProvider struct. With it, we have identified the usages of the DockerProvider, and its underlying Docker client, to close the client and avoid leaking Docker connections.As part of the PR we are moving the provider related code to a separate Go file, and identified that all
compose_test.go
paths were not usingfilepath
to create cross-OS paths.Why is it important?
It makes sure that we are not leaking Docker client connections, making sure it's closed everywhere, also providing a way to close the Docker Provider wrapper.
Related issues
Follow-ups
@Eun I'm not adding the test you provided in the original issue because I dit not see any difference running it against this branch or main (without the closes). Do you think we must add them to be covered? My only concern would be plugin the leak detector to the TestMain (
goleak.VerifyTestMain(m)
, see https://pkg.go.dev/go.uber.org/goleak#readme-quick-start):