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: container logging deadlocks #2791

Merged
merged 1 commit into from
Sep 25, 2024
Merged

fix: container logging deadlocks #2791

merged 1 commit into from
Sep 25, 2024

Conversation

stevenh
Copy link
Collaborator

@stevenh stevenh commented Sep 21, 2024

Refactor container log handling simplifying the logic fixing various issues with error handling and race conditions between the complex combinations of multiple channels that have been causing random deadlocks in tests.

The new version has simple for loop with an inter call to ContainerLogs and stdcopy.StdCopy leveraging an adapter between io.Writer and LogConsumer.

This could be used to easily expose separate stdout and stderr handlers.

Copy link

netlify bot commented Sep 21, 2024

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 68e58fb
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/66f19d222c8594000875a253
😎 Deploy Preview https://deploy-preview-2791--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.

@stevenh stevenh force-pushed the fix/logging-deadlock branch 3 times, most recently from de705d1 to 06b9a71 Compare September 21, 2024 12:55
@stevenh stevenh marked this pull request as ready for review September 21, 2024 18:03
@stevenh stevenh requested a review from a team as a code owner September 21, 2024 18:03
Copy link
Member

@mdelapenya mdelapenya left a comment

Choose a reason for hiding this comment

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

LGTM, just a few comments, none of them blockers.

docker.go Show resolved Hide resolved
docker.go Outdated Show resolved Hide resolved
docker.go Show resolved Hide resolved
docker_test.go Outdated Show resolved Hide resolved
Refactor container log handling simplifying the logic fixing various issues
with error handling and race conditions between the complex combinations of
multiple channels that have been causing random deadlocks in tests.

The new version has simple for loop with an inter call to ContainerLogs
and stdcopy.StdCopy leveraging an adapter between io.Writer and
LogConsumer.

This could be used to easily expose separate stdout and stderr handlers.
Copy link
Member

@mdelapenya mdelapenya left a comment

Choose a reason for hiding this comment

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

I think the code is much simpler to read, thanks!

LGTM

@mdelapenya mdelapenya self-assigned this Sep 25, 2024
@mdelapenya mdelapenya added the bug An issue with the library label Sep 25, 2024
@mdelapenya mdelapenya merged commit e02e8eb into main Sep 25, 2024
115 checks passed
@mdelapenya mdelapenya deleted the fix/logging-deadlock branch September 25, 2024 11:46
mdelapenya added a commit that referenced this pull request Sep 26, 2024
* main: (29 commits)
  fix: template for code generation (#2800)
  fix: update module path (#2797)
  fix: container logging deadlocks (#2791)
  chore: use a much smaller image for testing (#2795)
  fix: parallel containers clean race (#2790)
  fix(registry): wait for (#2793)
  fix: container timeout test (#2792)
  docs: document redpanda options (#2789)
  feat: support databend module (#2779)
  chore: golangci-lint 1.61.0 (#2787)
  fix(mssql): bump Docker image version (#2786)
  fix: handle 127 error code for podman compatibility (#2778)
  fix: do not override ImageBuildOptions.Labels when building from a Dockerfile (#2775)
  feat(mongodb): Wait for mongodb module with a replicaset to finish (#2777)
  fix(postgres): Apply default snapshot name if no name specified (#2783)
  fix: resource clean up for tests and examples (#2738)
  ci: add generate for mocks (#2774)
  fix: docker config error handling when config file does not exist (#2772)
  docs: refine heading badges in README (#2770)
  feat(wait): for file (#2731)
  ...
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Sep 26, 2024
* main:
  chore: update dockercfg module (testcontainers#2801)
  fix: template for code generation (testcontainers#2800)
  fix: update module path (testcontainers#2797)
  fix: container logging deadlocks (testcontainers#2791)
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.

2 participants