Fix Coast assigning ports already in use#118
Merged
jamiesunderland merged 1 commit intocoast-guard:mainfrom Mar 23, 2026
Merged
Fix Coast assigning ports already in use#118jamiesunderland merged 1 commit intocoast-guard:mainfrom
jamiesunderland merged 1 commit intocoast-guard:mainfrom
Conversation
Contributor
|
👀 |
jamiesunderland
approved these changes
Mar 23, 2026
Contributor
jamiesunderland
left a comment
There was a problem hiding this comment.
Going to merge, will QA a bit tonight on mac, make sure nothing is wrong before putting out a fix. Thanks for finding and putting up a fix.
Contributor
Author
|
Yes check it on macos please |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I found Coast was trying to assign ports already in use, leading to creating new coast environments sometimes failing randomly.
Coast was pre-allocating dynamic ports by doing a quick bind() probe and then immediately releasing the socket in port_manager.rs. That means “this port was free a moment ago,” not “this port is reserved.” On WSL there’s a second wrinkle: DinD publishes to 127.0.0.1 in dind.rs, and Docker Desktop’s Windows-side /forwards/expose layer can reject a port even when the Linux-side probe in WSL says it looks available.
I patched the run path in provision.rs so container creation/start now retries with a fresh set of dynamic ports when Docker reports a publish conflict, and I also made per-run port selection unique within a single instance in provision.rs.