Skip to content

Add pre-flight port check before cluster creation#182

Closed
bussyjd wants to merge 1 commit intomainfrom
preflight-port-check
Closed

Add pre-flight port check before cluster creation#182
bussyjd wants to merge 1 commit intomainfrom
preflight-port-check

Conversation

@bussyjd
Copy link
Collaborator

@bussyjd bussyjd commented Feb 18, 2026

Summary

  • Adds a pre-flight port availability check in stack.Up() before calling k3d cluster create
  • Probes ports 80, 8080, 443, and 8443 with net.Listen — if any are blocked, returns a clear error listing the conflicting port(s) and a sudo lsof remediation command
  • Adds unit tests for the port check and formatter helpers

Previously, if a port was in use (e.g., nginx, Apache, another k3d cluster), Docker would fail with a cryptic error and k3d would roll back the entire cluster creation with no actionable guidance.

Test plan

  • go test ./internal/stack/... — all 4 new tests pass
  • go build ./cmd/obol — compiles cleanly
  • Manual: bind port 443 (python3 -c "import socket; s=socket.socket(); s.bind(('',443)); s.listen(1); input()"), run obol stack up, verify clear error message
  • Manual: release port, run obol stack up, verify cluster creates normally

When `obol stack up` creates a new cluster, k3d tries to bind host
ports 80, 8080, 443, and 8443. If any are already in use, Docker
fails with a cryptic error and rolls back the entire cluster.

Add a `checkPortsAvailable()` pre-flight check that probes each
required port with `net.Listen` before invoking k3d. On conflict,
the error message lists the blocked port(s) and shows a `sudo lsof`
command to identify the offending process.
@bussyjd bussyjd requested a review from OisinKyne February 18, 2026 15:41
@OisinKyne OisinKyne closed this Feb 19, 2026
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

Comments