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

fix: avoid deadlocks when Docker is not available #1645

Merged
merged 1 commit into from
Sep 20, 2023

Conversation

mdelapenya
Copy link
Member

What does this PR do?

It restores the state of the sync.Once instance out of the Do block, which was incorrect, and buggy.

Before the changes, a panic was raised, but now we'll have a proper error message:

--- FAIL: TestContainerAttachedToNewNetwork (26.59s)
    docker_test.go:78: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?: failed to create network

Why is it important?

Removes a deadlock in the case the tests are run without Docker already running on the system.

Related issues

How to test this PR

  1. Stop Docker (or its alternatives: Testcontainers Desktop, Podman...)
  2. Run a test using testcontainers-go

Expected result: the test fail with a proper error message that Docker is not running
Before this PR: the test panicked with a deadlock.

@mdelapenya mdelapenya requested a review from a team as a code owner September 20, 2023 09:04
@mdelapenya mdelapenya self-assigned this Sep 20, 2023
@netlify
Copy link

netlify bot commented Sep 20, 2023

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 7ef1d90
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/650ab59ebb9a3a0007e4cbba
😎 Deploy Preview https://deploy-preview-1645--testcontainers-go.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mdelapenya mdelapenya added the bug An issue with the library label Sep 20, 2023
@mdelapenya mdelapenya merged commit 3d5837d into testcontainers:main Sep 20, 2023
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Sep 20, 2023
* main:
  docs: have common options in a common markdown file (testcontainers#1648)
  feat: add functional option for startup commands (testcontainers#1647)
  fix: support running the semver Docker image interactively (testcontainers#1646)
  fix: proper next version
  chore: prepare for next minor development cycle ()
  chore: use new version (v0.24.1) in modules and examples
  fix: avoid deadlocks when Docker is not available (testcontainers#1645)
@mdelapenya mdelapenya deleted the fix-docker-check branch September 26, 2023 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue with the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant