Skip to content

fix(stack): recreate containers whose published host port was taken before start - #7081

Merged
jgoux merged 2 commits into
developfrom
juliengoux/stack-podman-port-collision-retry
Oct 12, 2026
Merged

jgoux merged 2 commits into
developfrom
juliengoux/stack-podman-port-collision-retry

Conversation

@jgoux

@jgoux jgoux commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

TL;DR

stops a container service from failing to start when its published host port is taken between create and start.

whats broken?

containers publish with an engine-chosen host port (127.0.0.1::<port>). Podman picks that port at create by opening and closing a socket, and pasta only binds it at start. Anything that grabs the port in between, such as an outbound connection from another stack, fails the start with Listen failed for HOST TCP port …: Address in use.

now fixed by:

  • pasta's "Address in use" is classified as a port-allocation failure, like Docker's "port is already allocated".
  • a launch that fails with a port-allocation failure removes its container and creates a new one, which gets a new port, up to 3 attempts. The last failure is returned as before.

ref:

@jgoux
jgoux requested a review from a team as a code owner October 9, 2026 15:55
@jgoux jgoux self-assigned this Oct 9, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🤖 AI Review

Both independent reviews completed; Codex reported no findings. Code inspection confirms one minor resource-lifetime issue and two diagnostic nits. The tracing finding is narrowed to the verified missing attempt count; its claim that every existing retry uses the helper is false. No major or critical issues were verified. Tests were read but not executed.

Findings

Severity Location Category Sources Claim
🟡 MINOR packages/stack/src/runtime/Container.ts:1129 resource-management claude Abandoned retry attempts retain their environment directories and cleanup finalizers until the caller's scope closes. A successful service launch after collisions therefore keeps up to two unnecessary environment files, potentially containing secrets, for the service session's lifetime.
⚪ NIT packages/stack/src/runtime/Container.ts:1136 conventions claude The launch span records retry.attempt_count only after removal succeeds and another attempt is scheduled. First-attempt success, first-attempt terminal failure, and removal failure before the first retry omit the count.
⚪ NIT packages/stack/src/runtime/Container.ts:1135 error-handling claude If removing a collided container fails, the retry branch replaces the removal failure with the original launch error without explicitly logging or preserving the cleanup failure, obscuring why retrying stopped.

Stats

Claude findings: 3 · Codex findings: 0 · Confirmed: 3 · Refuted: 0 · Uncertain: 0


Models: claude-opus-5-5 + gpt-6.1-sol · Trigger: auto · Workflow run

This review runs once per PR. A maintainer can request another with a /ai-review comment.

Comment thread packages/stack/src/runtime/Container.ts Outdated
Comment thread packages/stack/src/runtime/Container.ts Outdated
Comment thread packages/stack/src/runtime/Container.ts Outdated
@jgoux
jgoux enabled auto-merge October 9, 2026 16:24
@jgoux
jgoux added this pull request to the merge queue Oct 9, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 9, 2026
@jgoux
jgoux added this pull request to the merge queue Oct 12, 2026
Merged via the queue into develop with commit 2e1f657 Oct 12, 2026
41 checks passed
@jgoux
jgoux deleted the juliengoux/stack-podman-port-collision-retry branch October 12, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants