Repository navigation
feat(lanes): a lane on a node relays its UDP ports (ADR-0056) - #236
Merged
Merged
Conversation
A UDP session is its own tunnel (`Upgrade: devstack-udp` on the lane
daemon's `/v1/tunnel/{port}`), each datagram a length-prefixed frame; the
requester keys sessions by the client's address with a 60 s idle timeout,
the lane daemon opens a socket per session towards the container. The
requester asks for it at the start, so an older peer leaves UDP ports
marked as not forwarded, with the reason. Linked from ADR-0029.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… (ADR-0056)
A container port published as UDP on a lane on a node is no longer only
named as not forwarded: the requester binds it on loopback at the lane's
port and relays it, a tunnel per client address (`Upgrade: devstack-udp`
on the lane daemon's `/v1/tunnel/{port}`), each datagram a frame of its
length (two bytes, big-endian) and its bytes. A session ends after 60 s
without a datagram either way; nothing is held while a container starts.
The lane daemon sends a session's datagrams from a socket of its own to
the container on the lane's network.
- `udprelay`: framing, the requester's session table (limits, retry after
a tunnel that did not open), the lane daemon's session.
- The requester asks for UDP when it starts the lane (`relay_udp`); a node
that relays tells the lane daemon (`udp` in its file) and answers with
`infra_udp_ports`. An older requester or node leaves the ports
`not_forwarded`; the lane then says why (`not_forwarded_reason` in
`GET /v1/lanes`, `devstack lane list`, the dashboard's lane header).
- A lane carried over a restart (ADR-0052) keeps its UDP ports.
- Docs: pool.md, dashboard-api.md, the devstack skill.
- Tests: framing, session table, idle timeout, a refused tunnel; an end to
end test through a real lane daemon's tunnel to an echo socket, without
Docker.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
macOS refuses to send a UDP datagram larger than the socket's send buffer, 9 KiB by default (`net.inet.udp.maxdgram`): the relay's 60 KB test datagram failed with EMSGSIZE on the macos-14 runner. Both relays raise a socket's send and receive buffers to hold any datagram a frame carries, never lowering them; ADR-0056 point 5 says so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
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.
Implements #219, the long-term part of #192: UDP ports of a lane on a pool node are forwarded to the requester, through the node tunnel.
ADR-0056 is Proposed: this PR merges once the owner accepts it.
ADR-0056, in short
Upgrade: devstack-udp, on the lane daemon's existing/v1/tunnel/{port}, spliced by the node agent like a TCP tunnel. Each datagram is a frame: its length as two bytes, big-endian, then the bytes. No session id: the tunnel is the session.relay_udpin the start request; a node that relays writesudpinto the lane daemon's file and answersinfra_udp_ports. Only then does the lane daemon stop listing UDP asnot_forwarded. An older requester: ports staynot_forwardedas today. An older node: nothing is relayed, and the lane says why (not_forwarded_reason). A lane carried over a restart (ADR-0052) keeps its UDP ports.http/httpsservices only, so there is no UDP to relay there; SCTP stays not forwarded; local lanes are unchanged (Docker publishes UDP).ADR-0029's
Relatedline and index row link ADR-0056.What changes
crates/devstack-daemon/src/udprelay.rs(new): framing, the requester's relay and session table, the lane daemon's session./v1/tunnel/{port}withdevstack-udp(api.rs),infra_udp(supervisor/infra.rs),udpin the agent's file decidesnot_forwarded(external.rs).remote.rs): UDP listeners next to the TCP ones (a shared bind-and-retry),open_tunnelfor both protocols,relay_udpin the start,Carried.udp_ports,not_forwarded_reason;LaneView.not_forwarded_reason(lanes.rs).node.rs,lanerun.rs,nodeclient.rs):Start.relay_udp,LaneState.infra_udp_ports,udpwritten into the lane daemon's file.devstack lane listgives the reason (UDP port 5353 is not forwarded to this machine (the node build-1 runs devstack 0.19.0, which forwards TCP only: devstack 0.20.0 or later there relays UDP)).docs/pool.md,docs/dashboard-api.md(thedevstack-udptunnel,not_forwarded_reason), thedevstackskill.socket2(MIT OR Apache-2.0, already in the lock through tokio): the relays raise a UDP socket's send and receive buffers to hold any datagram, as macOS sends at most 9 KiB by default (found by the macos-14 runner: EMSGSIZE on a 60 KB datagram).Wire compatibility: every new field is additive with
skip_serializing_if; an older peer ignores it.Tests
udprelay): encode/decode, a stream cut inside a frame, the session table (keyed by client, stale ids, backoff, full), the idle timeout on both sides, a tunnel that does not open (no hold, no retry storm), a dropped relay letting its port go; in-process pipes between relay andservewith a real UDP echo socket.external.rs,lanerun.rs,remote.rs(not_forwarded_reason,Carried),client.rs,ui/src/lib/lanes.test.ts.crates/devstack/tests/udp_relay.rs, runs on every OS, no Docker): a realdevstack daemonwithDEVSTACK_EXTERNAL_INFRAnaming an echo socket as the container; this machine's relay opens sessions as HTTP upgrades on its/v1/tunnel/{port}; datagrams (including 32 KB) go there and back, one session per client, a TCP-only port refused.cargo fmt --all,cargo clippy --workspace --all-targets --locked -- -D warnings(Windows), and clippy foraarch64-apple-darwinandx86_64-unknown-linux-gnu: clean.cargo testfor devstack-daemon (lib), devstack-node (lib and tests), devstack (bin,udp_relay), devstack-skills: pass.ui: typecheck, vitest (69), build: pass.remote_lane.rs,lanerun.rs, opt-in), so the path through a real node agent and a real container is not exercised here.Closes #219
🤖 Generated with Claude Code