fix: check if the discovered docker socket responds#2741
fix: check if the discovered docker socket responds#2741mdelapenya merged 26 commits intotestcontainers:mainfrom
Conversation
✅ Deploy Preview for testcontainers-go ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
This reverts commit c6c4832.
This reverts commit fbadada.
This reverts commit 19fb55b.
… resolution This way the tests are able to verify if the socket/host is reachable by calling a mock client. The production code will use the default callback check, which calls a vanilla docker client using the discovered host as host
stevenh
left a comment
There was a problem hiding this comment.
Seems like this might have some edge cases, so have asked a few questions.
stevenh
left a comment
There was a problem hiding this comment.
Looks good, just one nit, if you're so inclined.
* main: chore: use new testcontainers/ryuk:0.9.0 image (testcontainers#2750) chore(deps): bump minimal Go version from 1.21 to 1.22 (testcontainers#2743) chore(deps): bump github/codeql-action from 3.24.9 to 3.25.15 (testcontainers#2677)
| dockerHost := extractDockerHost(ctx) | ||
| dockerHost, err := extractDockerHost(ctx) | ||
| if err != nil { | ||
| panic(err) // Docker host is required to get the Docker socket |
There was a problem hiding this comment.
bug: This results in ExtractDockerSocket panic which is used in other non internal functions including its namesake ExtractDockerSocket none of which mention they can panic.
There was a problem hiding this comment.
I added comments to the functions, could you please check that? 🙏
stevenh
left a comment
There was a problem hiding this comment.
I'm wondering if should make a breaking change to either return errors all the way or rename exposed to be "Must" functions, as even with it mentioned in the docs its easy to miss, resulting in unexpected failures.
stevenh
left a comment
There was a problem hiding this comment.
Thanks for going the extra mile on this, feels must better to make it explicit.
Just a couple of minor things to consider
* main: feat(wait): for file (#2731) feat(compose): select services via profiles (#2758) chore(deps): bump mkdocs-markdownextradata-plugin from 0.2.5 to 0.2.6 (#2761) fix: update template too (#2763) chore(deps): bump actions/checkout from 4.1.1 to 4.1.7 (#2762) chore(deps): bump mkdocs-include-markdown-plugin from 6.0.4 to 6.2.2 (#2760) fix: check if the discovered docker socket responds (#2741) Upgrade milvus-io/milvus-sdk-go to avoid checksum mismatch. (#2753) Fix trailing slash on Image Prefix (#2747) chore: use new testcontainers/ryuk:0.9.0 image (#2750) chore(deps): bump minimal Go version from 1.21 to 1.22 (#2743)
* main: docs: refine heading badges in README (testcontainers#2770) feat(wait): for file (testcontainers#2731) feat(compose): select services via profiles (testcontainers#2758) chore(deps): bump mkdocs-markdownextradata-plugin from 0.2.5 to 0.2.6 (testcontainers#2761) fix: update template too (testcontainers#2763) chore(deps): bump actions/checkout from 4.1.1 to 4.1.7 (testcontainers#2762) chore(deps): bump mkdocs-include-markdown-plugin from 6.0.4 to 6.2.2 (testcontainers#2760) fix: check if the discovered docker socket responds (testcontainers#2741) Upgrade milvus-io/milvus-sdk-go to avoid checksum mismatch. (testcontainers#2753) Fix trailing slash on Image Prefix (testcontainers#2747) chore: use new testcontainers/ryuk:0.9.0 image (testcontainers#2750)
* main: ci: add generate for mocks (testcontainers#2774) fix: docker config error handling when config file does not exist (testcontainers#2772) docs: refine heading badges in README (testcontainers#2770) feat(wait): for file (testcontainers#2731) feat(compose): select services via profiles (testcontainers#2758) chore(deps): bump mkdocs-markdownextradata-plugin from 0.2.5 to 0.2.6 (testcontainers#2761) fix: update template too (testcontainers#2763) chore(deps): bump actions/checkout from 4.1.1 to 4.1.7 (testcontainers#2762) chore(deps): bump mkdocs-include-markdown-plugin from 6.0.4 to 6.2.2 (testcontainers#2760) fix: check if the discovered docker socket responds (testcontainers#2741) Upgrade milvus-io/milvus-sdk-go to avoid checksum mismatch. (testcontainers#2753) Fix trailing slash on Image Prefix (testcontainers#2747) chore: use new testcontainers/ryuk:0.9.0 image (testcontainers#2750)
What does this PR do?
This PR adds a check for each discovered Docker host in order to verify if a vanilla Docker client can talk to that host.
Why is it important?
It will remove the confusion when a testcontainers.properties file exists and the Testcontainers Desktop (TCD) app has been used in the past, adding a
tc.hostentry in the properties. In the case TCD is not running, and the container runtime is running (i.e. Docker Desktop), then the latter should be used. Before this fix, the code will cause the discovery algorithm to get the tc.host entry first (it simply exists) and use it, even though it's not responding.With this fix we'll fail if that Docker host is not accessible, continuing with the Docker host resolution.
Related issues