fix(provision/docker): set ExposedPorts alongside PortBindings (#16)#17
Merged
fix(provision/docker): set ExposedPorts alongside PortBindings (#16)#17
Conversation
Issue #16: the released v0.3.6 binary on ubuntu-latest produces a container with NetworkSettings.Ports == {} when invoked via `y-cluster provision -c <dir>` from bash, despite the in-process `go test -tags 'e2e,docker'` path succeeding on the same runner with the same SDK call shape. The container starts, k3s comes up internally, but no port forwards are published -- so the host-side /readyz probe can't reach 127.0.0.1:6443 and times out on every CI run. Root cause: the moby SDK's ContainerCreate doesn't auto-fill Config.ExposedPorts the way the Docker CLI's `docker run -p <host>:<guest>` does. Engine 28+ silently drops PortBindings that lack a matching ExposedPorts entry in some request shapes -- bash-invocation-of-released-binary turns out to be one of them, in-process go-test isn't. Build a network.PortSet alongside the PortMap in buildHostConfig and set it on Config.ExposedPorts before ContainerCreate. Each guest port in PortBindings now also appears in ExposedPorts; the daemon publishes all bindings exactly as `docker run -p` does on the same runner. The buildHostConfig signature gains a second return value (network.PortSet); the existing TestBuildHostConfig_PortBindingsHaveValidHostIP updates to discard it. New test TestBuildHostConfig_ExposedPortsMirrorBindings asserts the two sets agree key-by-key in both directions, so a future drift between PortBindings and ExposedPorts fails fast with a clear message instead of resurfacing as the silent-drop bug from issue #16 in a way that's only visible on a specific runner configuration. Verified: `go test ./pkg/provision/docker/...` green (in-process e2e exercises the SDK path against a real Docker daemon, asserts `docker port <name> 8080/tcp` resolves to a host port). The bash-from-released-binary path that issue #16 documents is reproducible only on the ystack acceptance runner; merging this should let that gate go green for the first time. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
solsson
added a commit
to Yolean/ystack
that referenced
this pull request
May 3, 2026
v0.3.7 (Yolean/y-cluster#17) sets Config.ExposedPorts alongside HostConfig.PortBindings on every docker.Provision call, matching what `docker run -p` does. Addresses Yolean/y-cluster#16: on ubuntu-latest CI the released binary's ContainerCreate produced NetworkSettings.Ports={} for the four-port ystack config even after the v0.3.6 HostIP fix, while plain `docker run -p ...` on the same runner published bindings cleanly. Verified via the e2e-cluster job whether the silent-drop is actually closed in the released-binary-from-bash path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
might fix #16