Skip to content

fix(ResourceReaper): Set wait strategy#1634

Merged
HofmeisterAn merged 2 commits intodevelopfrom
bugfix/set-wait-strategy-resource-reaper
Feb 13, 2026
Merged

fix(ResourceReaper): Set wait strategy#1634
HofmeisterAn merged 2 commits intodevelopfrom
bugfix/set-wait-strategy-resource-reaper

Conversation

@HofmeisterAn
Copy link
Copy Markdown
Collaborator

@HofmeisterAn HofmeisterAn commented Feb 13, 2026

What does this PR do?

The PR adds a wait strategy to the resource reaper configuration. The current retry implementation doesn't seem to work reliably in some environments. It's also no longer necessary, and much of the existing resource reaper implementation can be refactored, replaced, and simplified using the module API. Something I'll do in the future.

Adding the wait strategy ensures the container and service are fully up and accepting connections, making it more reliable to establish and maintain the Ryuk connection.

Why is it important?

Makes sure users don't run into issues when the sidecar container Ryuk starts.

Related issues

Summary by CodeRabbit

  • Bug Fixes

    • Improved container readiness detection to avoid startup races.
    • More reliable socket communication and buffer parsing to reduce connection and parsing errors.
  • Improvements

    • Better detection and fallback for Docker socket location with an override option.
    • Strengthened TCP handling for more robust connection stability.

@HofmeisterAn HofmeisterAn added the bug Something isn't working label Feb 13, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 13, 2026

Deploy Preview for testcontainers-dotnet ready!

Name Link
🔨 Latest commit 96bbc7f
🔍 Latest deploy log https://app.netlify.com/projects/testcontainers-dotnet/deploys/698f5a68bcb6ff0008a93bbc
😎 Deploy Preview https://deploy-preview-1634--testcontainers-dotnet.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 project configuration.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 13, 2026

Walkthrough

Adds an explicit readiness wait for the Resource Reaper container, tightens TCP socket read/ack parsing and keepalive handling, and improves Unix socket source resolution with a configurable override.

Changes

Cohort / File(s) Summary
Resource Reaper core
src/Testcontainers/Containers/ResourceReaper.cs
Adds WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("Started")). Reorders fluent constructor calls.
Connection & buffering logic
src/Testcontainers/Containers/ResourceReaper.cs
Enables TCP KeepAlive, replaces naive newline search with bounds-checked Array.IndexOf(..., 0, numberOfBytes), reads from GetBuffer() with length for ack matching, and adjusts initialization/maintenance flow for Ryuk connection.
Unix socket resolution
src/Testcontainers/Containers/ResourceReaper.cs
Determines Unix socket source from dockerEndpoint scheme with fallback to default path and support for TestcontainersSettings.DockerSocketOverride.

Sequence Diagram(s)

sequenceDiagram
  participant Client as Testcontainers Client
  participant Docker as Docker Daemon
  participant Ryuk as Resource Reaper Container
  participant Socket as TCP/Unix Socket

  Client->>Docker: Create & Start Ryuk container (with wait strategy)
  Docker-->>Ryuk: Start container, produce logs
  Ryuk-->>Docker: "Started" log line
  Docker-->>Client: Container reported ready
  Client->>Ryuk: TCP connect (with KeepAlive)
  Ryuk->>Socket: Listen on port/socket
  Socket-->>Client: Accept connection, send ack\n
  Client->>Client: Read buffer using GetBuffer()+Length, find '\n' with bounds-checked Array.IndexOf
Loading

Estimated Code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped to watch the reaper rise,
Logs whisper "Started" under open skies,
Sockets kept alive, bytes counted right,
Paths now fold to the unix light,
I nibble bugs and sleep tonight.

🚥 Pre-merge checks | ✅ 5 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(ResourceReaper): Set wait strategy' directly describes the main change and aligns with the primary objective of adding a wait strategy to resolve the race condition.
Description check ✅ Passed The description includes all mandatory sections: What does this PR do (explaining the wait strategy addition), Why is it important (addressing reliability), and Related issues (linking #1631).
Linked Issues check ✅ Passed The PR successfully implements the core requirement from #1631 by adding a wait strategy (WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("Started"))) to ensure the Ryuk container is fully ready before connection attempts.
Out of Scope Changes check ✅ Passed All changes in ResourceReaper.cs directly support the wait strategy objective: constructor reordering for clarity, TCP KeepAlive for reliability, buffering improvements for robustness, and Unix socket resolution refinements.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into develop

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/set-wait-strategy-resource-reaper

No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@HofmeisterAn HofmeisterAn merged commit 9b23f05 into develop Feb 13, 2026
185 of 218 checks passed
@HofmeisterAn HofmeisterAn deleted the bugfix/set-wait-strategy-resource-reaper branch February 13, 2026 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Missing wait strategy for resource reaper container start

1 participant