Skip to content

feat: containers can serve the main ports (ADR-0048) - #194

Merged
7schmiede merged 3 commits into
mainfrom
feat/main-ports
Oct 21, 2026
Merged

7schmiede merged 3 commits into
mainfrom
feat/main-ports

Conversation

@7schmiede

Copy link
Copy Markdown
Member

Implements ADR-0048 (accepted in #190); part 2 of #184. UDP is out of scope (#192).

What

[compose.<group>] main_ports = ["web"] names containers whose published TCP ports devstack holds in the main tree:

  • The main tree's overlay (.devstack/compose/<group>.main.yml, from devstack_compose::main_overlay) publishes their TCP ports on a loopback port Docker assigns (127.0.0.1::<target>). UDP ports, ranges and ports Docker assigns stay as the files say.
  • devstack binds the fixed port once compose up has let it go (Supervisor::hold_ports). It uses tcpfwd::Front::bind_at, on the address the Compose file names: every interface (IPv4 and IPv6) without one, loopback for 127.0.0.1.
  • sync_held, after every refresh, points each front:
    • at the container's instance port while it runs;
    • holds connections (60 s) while it is created or restarts;
    • refuses them while it is down;
    • forwards to the fixed port plus the lane's offset while a lane serves the main ports.
  • take_main / give_back flip the fronts (hold_for_lane). moves_main_slot counts main_ports, so a container-only stack with them is no longer refused (fix(daemon): serving the main ports refuses a stack of containers only #188). The refusal now names main_ports.
  • The main tree's own services keep reaching the main tree's container: published_ports stays the instance address, so there is no crosstalk. A lane's shared ports and its range are computed from the fixed ports (published_fixed).
  • The view: ContainerView.ports names the fixed port, and the new ContainerView.held gives the fixed and upstream port. The container detail page shows :8290 → :53994.
  • UDP ports of a named service get an infra event at the start: they stay Docker's (UDP ports: a lane on a node forwards them as TCP, and the main slot does not move them #192).
  • Config: main_ports must name services of services, and none of shared.

Tested by hand on Windows (Docker 29.8)

I built a busybox httpd stack with 18290:8080 and main_ports = ["web"]; the main tree serves main, and a lane's worktree serves lane:

  • after devstack up: the container is on 127.0.0.1:53994, devstack listens on 0.0.0.0:18290 and [::]:18290, and curl :18290 returns main;
  • the lane on its own port :18390 returns lane;
  • after promote --lane app-feat: :18290 returns lane;
  • after promote --lane main: :18290 returns main again.

One unrelated observation: devstack down --all --infra left both projects' containers running ("lanes were using it"). That predates this PR.

Tests

  • compose: main_overlay holds only the TCP ports of named services, keeps UDP and Docker-assigned ports, and errors on unknown names.
  • daemon: moves_main_slot counts main_ports.
  • config: validation of main_ports.
  • cargo clippy --workspace --all-targets -- -D warnings, cargo fmt --check and the workspace unit tests pass; UI typecheck and vitest pass.

Docs

docs/stack-file.md, docs/dashboard-api.md, the devstack-config skill, the CHANGELOG, and an as-built note in ADR-0048.

🤖 Generated with Claude Code

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.

1 participant