Repository navigation
Fix silent no-op retry when exposing host ports - #458
Merged
Merged
Conversation
… tunnel Testcontainers records the port in PortForwardingContainer.exposedPorts before booting sshd, so retrying after a failed start was a silent no-op and containers started without the host.testcontainers.internal entry. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01178nhmVuJrMJmVwwAoiQ5f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ServiceToServiceScopeConcurrencyintermittently fails inbeforeAllwith:(e.g. restatedev/restate run 40347565939, also seen on restatedev/restate#5639 and other unrelated branches.)
exposeHostPortretriesTestcontainers.exposeHostPorts(port), assuming a failed sshd start isn't cached. But in Testcontainers 2.0.4,PortForwardingContainer.exposeHostPortadds the port toexposedPortsbefore starting sshd and requesting the tunnel, and never removes it on failure. The retry then finds the port already recorded, returns immediately, and the wrapper reports success. Containers started afterwards get nohost.testcontainers.internalextra host, so discovery fails after its full 20s timeout.Fix
In
infra/.../hostPortForwarding.kt:(port, port)fromPortForwardingContainer.INSTANCE.exposedPorts, so the next attempt actually boots sshd and requests the forward. Only the failed port is removed; tunnels other test classes rely on are untouched (unlikereset()).exposeHostPortsreturns, checkgetNetwork()is present (i.e. the sshd container is running); otherwise throw so the retry kicks in.Validation
Networksetup asRestateDeployer, by forcing the first sshd start to fail: baseline wrapper reports success with no/etc/hostsentry 3/3; with this fix the retry succeeds 3/3. An already-running tunnel and other ports exposed in parallel were unaffected.:infra:compileKotlinand:infra:spotlessCheckpass. VerifiedexposedPorts,getNetwork()andINSTANCEexist with these names in Testcontainers 2.0.4.ServiceToServiceScopeConcurrencyclass locally.Generated by Claude Code