diff --git a/crates/devstack-daemon/src/external.rs b/crates/devstack-daemon/src/external.rs index 46753b9b..7db117de 100644 --- a/crates/devstack-daemon/src/external.rs +++ b/crates/devstack-daemon/src/external.rs @@ -69,18 +69,62 @@ impl ExternalGroup { } } +/// A container port and its protocol, as the agent's file keys them: `5432` +/// for TCP (as every agent wrote a port), `53/udp` for another protocol, so +/// a service's `53/tcp` and `53/udp` are two entries (#192). +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] +pub struct PortKey { + pub port: u16, + /// Lower case; `tcp` sorts before `udp`, so a port's TCP entry comes + /// first. + pub protocol: String, +} + +impl PortKey { + /// devstack forwards TCP only (#192). + pub fn is_tcp(&self) -> bool { + self.protocol == "tcp" + } +} + +impl std::str::FromStr for PortKey { + type Err = String; + + fn from_str(s: &str) -> Result { + let (port, protocol) = s.split_once('/').unwrap_or((s, "tcp")); + let port = port + .trim() + .parse() + .map_err(|_| format!("`{s}` is no port"))?; + let protocol = match protocol.trim().to_ascii_lowercase() { + p if p.is_empty() => "tcp".to_string(), + p => p, + }; + Ok(Self { port, protocol }) + } +} + +impl<'de> Deserialize<'de> for PortKey { + fn deserialize>(d: D) -> Result { + String::deserialize(d)? + .parse() + .map_err(serde::de::Error::custom) + } +} + #[derive(Debug, Clone, Deserialize, Default)] pub struct ExternalService { #[serde(default)] pub environment: BTreeMap>, /// Container port -> address the lane container reaches it at. #[serde(default)] - pub ports: BTreeMap, + pub ports: BTreeMap, /// Container port -> the port it is on at the lane's developer's machine /// (what a local lane would publish it on): its links point there, and /// the developer's tunnels to it come in on that port (ADR-0029 point 4). + /// A port of another protocol than TCP is listed, but not forwarded. #[serde(default)] - pub published: BTreeMap, + pub published: BTreeMap, /// Empty: not started (a parked service that is only an environment source). #[serde(default)] pub state: String, @@ -94,6 +138,43 @@ pub struct ExternalService { pub memory: Option, } +impl ExternalService { + /// Its TCP ports where the developer reaches them, `(container port, + /// port there)`: what is forwarded, and linked. + pub fn forwarded(&self) -> impl Iterator + '_ { + self.published + .iter() + .filter(|(k, _)| k.is_tcp()) + .map(|(k, h)| (k.port, *h)) + } + + /// Its published ports of another protocol, as the developer would + /// reach them (`5353/udp`): not forwarded, devstack forwards TCP only + /// (#192). + pub fn not_forwarded(&self) -> Vec { + self.published + .iter() + .filter(|(k, _)| !k.is_tcp()) + .map(|(k, h)| format!("{h}/{}", k.protocol)) + .collect() + } + + /// Its ports as the view shows them, as the developer reaches them + /// (`15432->db:5432`, `5353/udp->dns:53`). + pub fn shown_ports(&self) -> Vec { + self.ports + .iter() + .map(|(k, a)| { + let at = self.published.get(k).copied().unwrap_or(k.port); + match k.is_tcp() { + true => format!("{at}->{a}"), + false => format!("{at}/{}->{a}", k.protocol), + } + }) + .collect() + } +} + /// The file `DEVSTACK_EXTERNAL_INFRA` names, if it is set. pub fn path() -> Option { std::env::var_os("DEVSTACK_EXTERNAL_INFRA") @@ -147,7 +228,7 @@ mod tests { ) .unwrap(); let g = &x.groups["app"]; - assert_eq!(g.services["db"].ports[&5432], "db:5432"); + assert_eq!(g.services["db"].ports[&"5432".parse().unwrap()], "db:5432"); assert_eq!(g.services["api"].state, ""); assert_eq!(g.services["api"].environment["X"], None); assert_eq!( @@ -165,4 +246,28 @@ mod tests { (Some(1_760_000_000_000), Some(12.5), Some(1 << 20)) ); } + + #[test] + fn a_port_of_another_protocol_is_its_own_and_not_forwarded() { + let x: super::ExternalInfra = serde_json::from_str( + r#"{"groups":{"app":{"services":{"dns":{ + "ports":{"53":"dns:53","53/udp":"dns:53","8080/tcp":"dns:8080"}, + "published":{"53":5453,"53/udp":5453,"8080/tcp":8180}, + "state":"running"}}}}}"#, + ) + .unwrap(); + let dns = &x.groups["app"].services["dns"]; + assert_eq!(dns.ports.len(), 3, "53/tcp and 53/udp are two"); + assert_eq!( + dns.forwarded().collect::>(), + [(53, 5453), (8080, 8180)] + ); + assert_eq!(dns.not_forwarded(), ["5453/udp"]); + assert_eq!( + dns.shown_ports(), + ["5453->dns:53", "5453/udp->dns:53", "8180->dns:8080"] + ); + assert!("x/udp".parse::().is_err()); + assert_eq!("53/UDP".parse::().unwrap().protocol, "udp"); + } } diff --git a/crates/devstack-daemon/src/lanes.rs b/crates/devstack-daemon/src/lanes.rs index f54145db..050a3691 100644 --- a/crates/devstack-daemon/src/lanes.rs +++ b/crates/devstack-daemon/src/lanes.rs @@ -90,6 +90,10 @@ pub struct LaneView { /// or does not say which (ADR-0031, amended 2026-10-19). #[serde(skip_serializing_if = "Option::is_none")] pub node_warning: Option, + /// Of a lane on a node, its containers' published ports this machine + /// does not forward (`5353/udp`): devstack forwards TCP only (#192). + #[serde(skip_serializing_if = "Vec::is_empty")] + pub not_forwarded: Vec, /// A start on a node or a move under way, or one that failed lately. #[serde(skip_serializing_if = "Option::is_none")] pub moving: Option, @@ -105,8 +109,15 @@ pub struct LaneView { /// Of a lane, what the lists show that changes on its own: name, services /// and containers running and all, its node's error, whether it moves, its -/// notices. -type Shown = (String, [usize; 4], Option, bool, Vec); +/// notices, its ports not forwarded. +type Shown = ( + String, + [usize; 4], + Option, + bool, + Vec, + Vec, +); /// The notice of a lane whose worktree git lists but is not there, missing /// since `since` (unix ms): the lane goes after [`MISSING_GRACE`]. @@ -1087,6 +1098,7 @@ impl Lanes { v.node_error, v.moving.is_some(), v.notices, + v.not_forwarded, ) }) .collect() @@ -1660,7 +1672,11 @@ impl Lanes { pool: on_node.map(|r| r.pool.clone()), shared_with: self.share_of(&k.entry.name), profile: self.profiles.lock().unwrap().get(&k.entry.name).cloned(), - node_error: node_state.and_then(|st| st.error()), + node_error: node_state.as_ref().and_then(|st| st.error()), + not_forwarded: node_state + .as_ref() + .map(|st| st.not_forwarded.clone()) + .unwrap_or_default(), node_warning: on_node .and_then(|r| r.warning.clone()) .or_else(|| moves.get(&k.entry.name).and_then(|m| m.warning.clone())), diff --git a/crates/devstack-daemon/src/remote.rs b/crates/devstack-daemon/src/remote.rs index a0916b6d..d0cde181 100644 --- a/crates/devstack-daemon/src/remote.rs +++ b/crates/devstack-daemon/src/remote.rs @@ -42,6 +42,9 @@ pub struct RemoteState { pub ended: bool, /// Its services that run now (healthy or running), by name. pub active: Vec, + /// Its containers' published ports this machine does not forward + /// (`5353/udp`): devstack forwards TCP only (#192). + pub not_forwarded: Vec, } impl RemoteState { @@ -1200,6 +1203,7 @@ impl RemoteLane { st.containers_running = all.iter().filter(|c| c["state"] == "running").count(); st.containers = all.len(); st.active = active; + st.not_forwarded = not_forwarded(&all); } if !self.tick(STATE_EVERY).await { return; @@ -1487,6 +1491,23 @@ fn not_written(failed: &[String]) -> String { s } +/// The published ports of a lane's containers (its view's, read as JSON) +/// that this machine does not forward, each once, in order (`5353/udp`). +/// A lane daemon from before #192 does not say. +fn not_forwarded(containers: &[serde_json::Value]) -> Vec { + let mut out: Vec = containers + .iter() + .flat_map(|c| c["not_forwarded"].as_array().cloned().unwrap_or_default()) + .filter_map(|p| p.as_str().map(str::to_string)) + .collect(); + out.sort_by_key(|p| { + let port = p.split('/').next().and_then(|n| n.parse::().ok()); + (port, p.clone()) + }); + out.dedup(); + out +} + /// What a lease offer says of the node's and the coordinator's devstack: /// `Err` for a node with another pool protocol, a warning for another /// release or one that does not say. @@ -1805,4 +1826,19 @@ members = ["api"] "not written on the node: f1: denied" ); } + + #[test] + fn a_lanes_ports_not_forwarded_are_listed_once_in_order() { + let containers: Vec = serde_json::from_str( + r#"[{"service":"dns","not_forwarded":["10053/udp","5453/udp"]}, + {"service":"voice","not_forwarded":["5453/udp"]}, + {"service":"db","ports":["15432->db:5432"]}]"#, + ) + .unwrap(); + assert_eq!(super::not_forwarded(&containers), ["5453/udp", "10053/udp"]); + assert!( + super::not_forwarded(&containers[2..]).is_empty(), + "an older lane daemon's" + ); + } } diff --git a/crates/devstack-daemon/src/state.rs b/crates/devstack-daemon/src/state.rs index 72b65392..8a16ae13 100644 --- a/crates/devstack-daemon/src/state.rs +++ b/crates/devstack-daemon/src/state.rs @@ -138,6 +138,11 @@ pub struct ContainerView { /// container may look healthy. A restart of the container fixes it. #[serde(skip_serializing_if = "Vec::is_empty", default)] pub unreachable: Vec, + /// Of a lane on a node, its published ports of another protocol than + /// TCP (`5353/udp`): devstack forwards TCP only, so the developer's + /// machine does not reach them (#192). + #[serde(skip_serializing_if = "Vec::is_empty", default)] + pub not_forwarded: Vec, /// Its fixed ports devstack holds (`main_ports`, ADR-0048): `port` the /// fixed one, `upstream` where it forwards now (the container's /// instance port, or a lane's port while that serves the main ports). diff --git a/crates/devstack-daemon/src/supervisor/infra.rs b/crates/devstack-daemon/src/supervisor/infra.rs index 839916b1..6b0dba4f 100644 --- a/crates/devstack-daemon/src/supervisor/infra.rs +++ b/crates/devstack-daemon/src/supervisor/infra.rs @@ -426,6 +426,7 @@ impl Supervisor { urls: self.container_urls(group, &c.service, &ports), ports, unreachable: Vec::new(), + not_forwarded: Vec::new(), held, } } @@ -1032,7 +1033,7 @@ impl Supervisor { /// In a lane on a node: the container address a tunnel on `port` goes /// to, when `port` is where a container of the lane is published for its - /// developer (ADR-0029 point 4). + /// developer (ADR-0029 point 4). A tunnel carries TCP (#192). pub fn infra_tunnel(&self, port: u16) -> Option { let ext = crate::external::read(&self.external_infra()?).ok()?; ext.groups @@ -1041,7 +1042,7 @@ impl Supervisor { .find_map(|s| { s.published .iter() - .find(|(_, h)| **h == port) + .find(|(k, h)| k.is_tcp() && **h == port) .and_then(|(target, _)| s.ports.get(target).cloned()) }) } @@ -1073,36 +1074,36 @@ impl Supervisor { view.error = Some(e); } for (svc, s) in eg.services { - for (port, addr) in &s.ports { + for (key, addr) in &s.ports { // A published container is reached on loopback, // as on the developer's machine: the same // addresses for the services (`rewrite_hosts`), - // and loopback where they insist on it. - let at = match s.published.get(port) { - Some(host) if self.loopback_forward(*host, addr) => { + // and loopback where they insist on it. A + // forward carries TCP; a UDP port is reached at + // its container (#192). + let at = match s.published.get(key) { + Some(host) + if key.is_tcp() && self.loopback_forward(*host, addr) => + { format!("127.0.0.1:{host}") } _ => addr.clone(), }; - cache.published.insert((g.clone(), svc.clone(), *port), at); + // A port's TCP entry comes first, and stays. + cache + .published + .entry((g.clone(), svc.clone(), key.port)) + .or_insert(at); } cache .envs .insert((g.clone(), svc.clone()), s.environment.clone()); if !s.state.is_empty() { // Shown, and linked, as the developer reaches it. - let ports: Vec = s - .ports - .iter() - .map(|(p, a)| match s.published.get(p) { - Some(h) => format!("{h}->{a}"), - None => format!("{p}->{a}"), - }) - .collect(); + let ports = s.shown_ports(); let here: Vec = s - .published - .values() - .map(|h| format!("localhost:{h}")) + .forwarded() + .map(|(_, h)| format!("localhost:{h}")) .collect(); view.containers.push(ContainerView { service: svc.clone(), @@ -1113,6 +1114,7 @@ impl Supervisor { urls: self.container_urls(&g, &svc, &here), ports, unreachable: Vec::new(), + not_forwarded: s.not_forwarded(), held: Vec::new(), managed: true, }); @@ -1499,6 +1501,7 @@ mod tests { ports: Vec::new(), urls: Vec::new(), unreachable: Vec::new(), + not_forwarded: Vec::new(), held: Vec::new(), managed, } diff --git a/crates/devstack-node/src/lanerun.rs b/crates/devstack-node/src/lanerun.rs index 8397770a..02746f2f 100644 --- a/crates/devstack-node/src/lanerun.rs +++ b/crates/devstack-node/src/lanerun.rs @@ -187,7 +187,7 @@ fn initial_infra( let ports: BTreeMap = m .ports .iter() - .map(|p| (p.target.to_string(), format!("{svc}:{}", p.target))) + .map(|p| (port_key(p), format!("{svc}:{}", p.target))) .collect(); // Where a local lane would publish each port: the host port // of the Compose files, moved by the lane's offset. @@ -196,11 +196,18 @@ fn initial_infra( .iter() .filter_map(|p| { let host: u16 = p.published.as_deref()?.trim().parse().ok()?; - Some((p.target.to_string(), host.checked_add(port_offset)?)) + Some((port_key(p), host.checked_add(port_offset)?)) }) .collect(); + // The requester forwards TCP only (#192): a UDP port stays + // listed, for the daemon to say it is not forwarded. if starts { - infra_ports.extend(published.values().copied()); + infra_ports.extend( + published + .iter() + .filter(|(key, _)| !key.contains('/')) + .map(|(_, host)| *host), + ); } ( svc.clone(), @@ -228,6 +235,23 @@ fn initial_infra( (serde_json::json!({ "groups": infra }), infra_ports) } +/// A Compose port without a protocol, or `tcp`, is TCP. +fn is_tcp(p: &devstack_compose::PortModel) -> bool { + p.protocol + .as_deref() + .is_none_or(|x| x.is_empty() || x.eq_ignore_ascii_case("tcp")) +} + +/// How the lane's daemon's file keys a container port: `5432` for TCP, as +/// every agent wrote it, `53/udp` for another protocol, so a service's +/// `53/tcp` and `53/udp` stay two (#192). +fn port_key(p: &devstack_compose::PortModel) -> String { + match (is_tcp(p), p.protocol.as_deref()) { + (false, Some(proto)) => format!("{}/{}", p.target, proto.to_ascii_lowercase()), + _ => p.target.to_string(), + } +} + fn docker_for(args: &[&str], within: Duration) -> Result { let mut cmd = Command::new("docker"); cmd.args(args); @@ -1132,6 +1156,38 @@ mod tests { assert_eq!(ports, [15532], "only what the group starts is forwarded"); } + #[test] + fn a_udp_port_is_listed_with_its_protocol_and_not_forwarded() { + let model = devstack_compose::parse_config( + r#"{"name":"shop","services":{ + "dns":{"image":"dnsmasq","ports":[ + {"target":53,"published":"5353","protocol":"tcp"}, + {"target":53,"published":"5353","protocol":"udp"}, + {"target":8080,"published":"8080"}]}, + "voice":{"image":"sip","ports":[{"target":5060,"published":"5060","protocol":"udp"}]}}}"#, + ) + .unwrap(); + let g = Group { + name: "app".into(), + project: "shop-ab12".into(), + files: Vec::new(), + env_files: Vec::new(), + networks: Vec::new(), + services: Vec::new(), + dir: PathBuf::from("/compose"), + }; + let (infra, ports) = initial_infra(&[("app".into(), g, model)], 100); + let dns = &infra["groups"]["app"]["services"]["dns"]; + assert_eq!(dns["ports"]["53"], "dns:53"); + assert_eq!(dns["ports"]["53/udp"], "dns:53", "not folded into 53/tcp"); + assert_eq!(dns["published"]["53"], 5453); + assert_eq!(dns["published"]["53/udp"], 5453); + assert_eq!(dns["published"]["8080"], 8180); + let voice = &infra["groups"]["app"]["services"]["voice"]; + assert_eq!(voice["published"]["5060/udp"], 5160); + assert_eq!(ports, [5453, 8180], "TCP only, each once"); + } + #[test] fn names_built_for_a_member_are_its_own() { let a = secret_name("s1", &["m1", "shop-ab", "api"]); diff --git a/crates/devstack/src/client.rs b/crates/devstack/src/client.rs index 5a1334de..b249be47 100644 --- a/crates/devstack/src/client.rs +++ b/crates/devstack/src/client.rs @@ -1355,6 +1355,9 @@ pub fn lane_list(stack_file: &Path) -> Result<()> { if let Some(w) = l["node_warning"].as_str() { troubles.push(format!("{name}: {w}")); } + if let Some(t) = not_forwarded_line(&l["not_forwarded"]) { + troubles.push(format!("{name}: {t}")); + } println!( "{:<24} {:<24} {:>8} {:>9} {:<5} {:<16} {}", name, @@ -1376,6 +1379,33 @@ pub fn lane_list(stack_file: &Path) -> Result<()> { Ok(()) } +/// A lane's `not_forwarded` (`["5353/udp"]`) as a line: `UDP port 5353 is +/// not forwarded ...`; `None` when there is none (#192). +fn not_forwarded_line(ports: &Value) -> Option { + let ports: Vec<(String, String)> = ports + .as_array()? + .iter() + .filter_map(Value::as_str) + .map(|p| { + let (port, proto) = p.split_once('/').unwrap_or((p, "udp")); + (proto.to_ascii_uppercase(), port.to_string()) + }) + .collect(); + let (first, rest) = ports.split_first()?; + let listed = if rest.iter().all(|(proto, _)| *proto == first.0) { + let numbers: Vec<&str> = ports.iter().map(|(_, n)| n.as_str()).collect(); + let s = if numbers.len() == 1 { "" } else { "s" }; + format!("{} port{s} {}", first.0, numbers.join(", ")) + } else { + let each: Vec = ports.iter().map(|(p, n)| format!("{p} {n}")).collect(); + format!("ports {}", each.join(", ")) + }; + let are = if ports.len() == 1 { "is" } else { "are" }; + Some(format!( + "{listed} {are} not forwarded to this machine (devstack forwards TCP only)" + )) +} + /// A lane's `moving` as a line: ` [2/3] sync: ...`. fn step_line(m: &Value) -> String { format!( @@ -2309,4 +2339,27 @@ data: {\"type\":\"line\",\"text\":\"c\"}\n\n"; assert!(pid_alive(std::process::id())); assert!(!pid_alive(u32::MAX - 1)); } + + #[test] + fn a_lanes_ports_not_forwarded_are_said() { + let line = |v: Value| not_forwarded_line(&v); + assert_eq!(line(serde_json::json!(null)), None, "an older daemon"); + assert_eq!(line(serde_json::json!([])), None); + assert_eq!( + line(serde_json::json!(["5353/udp"])).as_deref(), + Some("UDP port 5353 is not forwarded to this machine (devstack forwards TCP only)") + ); + assert_eq!( + line(serde_json::json!(["5060/udp", "5353/udp"])).as_deref(), + Some( + "UDP ports 5060, 5353 are not forwarded to this machine (devstack forwards TCP only)" + ) + ); + assert_eq!( + line(serde_json::json!(["5353/udp", "9000/sctp"])).as_deref(), + Some( + "ports UDP 5353, SCTP 9000 are not forwarded to this machine (devstack forwards TCP only)" + ) + ); + } } diff --git a/docs/dashboard-api.md b/docs/dashboard-api.md index 0ba80a95..308d6987 100644 --- a/docs/dashboard-api.md +++ b/docs/dashboard-api.md @@ -223,6 +223,7 @@ type InfraView = { group: string; project: string; containers: ContainerView[]; type ContainerView = { service: string; name: string; state: string; health: string; exit_code: number; ports: string[]; urls: string[]; // see below unreachable: string[]; // published ports Docker no longer forwards + not_forwarded?: string[]; // a lane on a node: its published ports of another protocol than TCP (`5353/udp`), not forwarded to the developer's machine (#192) held?: { port: number; upstream: number | null; active: number; served: number }[]; // its fixed ports devstack holds (`main_ports`, ADR-0048): `upstream` the container's instance port, or the lane's port while a lane serves the main ports; `ports` then names the fixed port managed: boolean }; // the group starts it (in its `services`); false: another container of the project @@ -242,6 +243,7 @@ type LaneView = { shared_with?: string[]; // ADR-0035: member ids, tags, `*` node_error?: string; // a sync or renewal that failed lately node_warning?: string; // its node or the coordinator runs another devstack, or does not say (ADR-0031 point 8) + not_forwarded?: string[]; // its containers' published ports not forwarded here (`5353/udp`): devstack forwards TCP only (#192) moving?: { kind: "start" | "move"; to: string; step: number; steps: number; what: string; since: number; phases?: { phase: string; ms: number }[]; phase_since?: number; error?: string; failed_at?: number }; // a start on a node or a move under way, or failed lately @@ -307,7 +309,7 @@ type UsageReport = { | `POST /v1/infra/check` | probe every ready container's published ports from this machine: `[{group, service, ports}]` that accept and close at once on three probes a second apart (Docker lost the port forward, or nothing listens inside); recorded as `ContainerView.unreachable`. The daemon also judges each container once it has been ready for 20 s, and probes a port found lost again every few seconds until it answers; a restart from devstack clears the verdict. A service with `after = ["compose.."]` restarts such a container before it starts, if it has been ready for 20 s and was not restarted for this in the last 10 minutes | | `GET /v1/infra/{group}/{service}/logs?tail=200&grep=&since=` | text, a container's output (`docker compose logs`), stdout and stderr merged by Docker's timestamps, each line starting with one; `since` as Docker takes it (`30m`); `502` when Docker fails. `/v1/services/{name}/logs` answers the same for a name that is no service but exactly one Compose service | | `GET /v1/infra/{group}/{service}/logs/stream?tail=500` | SSE (`tail` at most 5000): `{"type":"line","text":"..."}` per line of `docker compose logs --follow` (timestamped), the same events as a service's log stream; in a lane its own container, the main tree's for a `shared` one | -| `GET /v1/lanes` | JSON, the lanes: the repository's other worktrees ([ADR-0024](adr/0024-a-lane-is-a-supervisor-in-the-main-trees-daemon.md)), `[{name, path, branch, number, port_offset, active, owns_main, running, services, containers_running, containers, node?, pool?, shared_with?, profile?, node_error?}]`; `active`: started; `containers_running`/`containers`: its Compose containers devstack starts that run, and all (a stack of containers only shows by them that it runs); `node`: the node of the pool it runs on (absent: this machine), `pool`: that node's pool, `shared_with`: whom it is shared with (member ids, tags, `*`; absent: nobody), `profile`: the profile it runs with, `node_error`: what goes wrong with it now (a sync, a renewal, a port that cannot be forwarded here), each until it works again, several joined by `; `, `node_warning`: the node or the coordinator runs another devstack than this machine, or does not say which (from the lease on, so while it starts too; [ADR-0031](adr/0031-a-coordinator-places-lanes.md) point 8); `moving`: `{kind: start|move, to, step, steps, what, since, phases, phase_since, error?, failed_at?}` (`phases`: `[{phase, ms}]` over so far, `phase_since`: when the current one began) while a start on a node or a move runs, and for ten minutes after one failed; `removing`: `true` while the lane of a worktree that is gone is stopped and its data removed (it leaves the list after) | +| `GET /v1/lanes` | JSON, the lanes: the repository's other worktrees ([ADR-0024](adr/0024-a-lane-is-a-supervisor-in-the-main-trees-daemon.md)), `[{name, path, branch, number, port_offset, active, owns_main, running, services, containers_running, containers, node?, pool?, shared_with?, profile?, node_error?, node_warning?, not_forwarded?}]`; `active`: started; `containers_running`/`containers`: its Compose containers devstack starts that run, and all (a stack of containers only shows by them that it runs); `node`: the node of the pool it runs on (absent: this machine), `pool`: that node's pool, `shared_with`: whom it is shared with (member ids, tags, `*`; absent: nobody), `profile`: the profile it runs with, `node_error`: what goes wrong with it now (a sync, a renewal, a port that cannot be forwarded here), each until it works again, several joined by `; `, `node_warning`: the node or the coordinator runs another devstack than this machine, or does not say which (from the lease on, so while it starts too; [ADR-0031](adr/0031-a-coordinator-places-lanes.md) point 8); `not_forwarded`: its containers' published ports of another protocol than TCP (`5353/udp`), which run on the node but are not forwarded here (devstack forwards TCP only, #192; a lane daemon of an older devstack does not say); `moving`: `{kind: start|move, to, step, steps, what, since, phases, phase_since, error?, failed_at?}` (`phases`: `[{phase, ms}]` over so far, `phase_since`: when the current one began) while a start on a node or a move runs, and for ten minutes after one failed; `removing`: `true` while the lane of a worktree that is gone is stopped and its data removed (it leaves the list after) | | `POST /v1/lanes` | `{"path", "infra"?, "workers"?, "force"?, "on"?, "profile"?}`: start the lane of that worktree, with `profile` with that profile of its stack file ([ADR-0041](adr/0041-a-profile-says-how-a-lane-runs-for-a-purpose.md); `409` when the worktree's stack file has no such profile or it does not apply); with `on` (a node's name or member id, or `pool` for the coordinator to choose; in another pool than the default one `:`, or `` for its coordinator to choose, [ADR-0034](adr/0034-a-machine-can-belong-to-several-pools.md)) on that node of the pool instead, leased, synced and started there, its API passed through under `/v1/lanes/{lane}/v1/...` ([ADR-0025](adr/0025-a-lane-can-run-on-another-node.md)) (what `devstack up` in it does; `infra` starts the main tree's `shared` Compose services if needed, the lane's own containers start with its `up`; `workers` runs its background workers; `force` skips the memory check, which otherwise answers `409` with what the lane needs and what is free, ADR-0030), then `/v1/lanes/{lane}/v1/up` starts its services and its containers. `201` with its entry. With `on`: `202` with its entry once the lane is leased and admitted by the node; its sync and its start there (minutes on a first start: images pulled and built, containers created) go on in the background, shown as the entry's `moving` (`kind: "start"`, in `lanes` events and here). It runs there once `moving` is gone and `active` is `true`, which is once the lane's daemon answers there: its containers come up after, under it (#164; a node of an earlier release answers once they are healthy), and show as `created`, then `starting` and `healthy` in its `InfraView`s (then call `/v1/up`, which starts its services once their infrastructure is up); it failed when `moving` carries `error` (for ten minutes, until the lane stops, the main tree's `/v1/down` or a start of it here). What can be told at once is refused at once: no such worktree, a lane that runs elsewhere, no lease (`409` with the reason: no node, the coordinator or the node refuses, a node with another pool protocol). The same start asked again while it goes on answers `202` too; `201` when the lane runs on that node already. Up to 0.10.1 a start on a node answered `201` only when done. Worktrees are git's: there is no route that creates or removes one | | `POST /v1/lanes/{lane}/share` | `{"with"}`: share a lane on a node with others in its pool: member ids, tags, `*` for every member; `[]` for nobody ([ADR-0035](adr/0035-lanes-can-be-shared-with-the-pool.md)). They open its services and view it, read only ([ADR-0040](adr/0040-a-shared-lane-can-be-watched-like-ones-own.md)); `view`, a separate list up to 0.11.1, is ignored. Kept per lane, told the coordinator while it runs on a node. Answers with the lanes (`LaneView.shared_with`) | | `POST /v1/lanes/{lane}/reset` | a stopped lane's data goes, here and on the nodes it ran on (ADR-0038): `[Pruned]` (`{place, lane, bytes, why, removed, error}`; `removed: false` with `error` where it did not go, this machine's containers too); `409` while it runs | diff --git a/docs/pool.md b/docs/pool.md index bb531f0e..b40c0deb 100644 --- a/docs/pool.md +++ b/docs/pool.md @@ -198,6 +198,10 @@ devstack leases the lane, syncs the worktree to the node (by content, only what changed: a change within two seconds of saving, and everything compared every 30 s besides), starts it there and forwards its ports to your machine: `localhost:` reaches it as if it ran locally, its containers' ports too. +Forwarding carries TCP only: a container port published as UDP (`53/udp`, +a game's voice port) runs on the node but is not forwarded here. The lane's +page, its container's row and `devstack lane list` say so ("UDP port 5353 is +not forwarded to this machine"); keep such a lane local (#192). The dashboard shows where each lane runs, its start step by step, and offers **Start here / on a node / in the pool** for a lane that is not started. diff --git a/skills/devstack/SKILL.md b/skills/devstack/SKILL.md index af55f058..fffff001 100644 --- a/skills/devstack/SKILL.md +++ b/skills/devstack/SKILL.md @@ -60,7 +60,7 @@ Run from the repository root (devstack looks for `{{devstack:stack_file}}` there | `devstack lane start [--on ]` | start a lane from the main tree (or anywhere in the repository), as `devstack up` in its worktree does; `status` in the main tree lists the lanes in one line. **To run another branch or commit beside the main stack** (an end-to-end run against a given commit, a review): `git worktree add `, `devstack lane start ` (its ports are the main ports plus its offset, `devstack lane list`), test against those, `devstack lane stop `, `git worktree remove `. **For an acceptance run** use the stack file's profile if it has one (`status` lists none; `[profiles]` in the file): `devstack lane start --profile

--run` starts the lane as the profile says (a build instead of a dev server, workers, fresh data, the suite's env) and runs its suite command. A worktree another tool or script created is a lane too: starting it gives its own ports, containers and database without building a separate environment | | `devstack lane reset ` / `devstack lane prune [--older-than 7d] [--dry-run]` | throw a stopped lane's data away (it starts fresh, seeded again); remove what lanes whose worktree is gone left behind, here and on the pool's nodes. A lane on a node keeps its data there between starts. Ask the user before either: data goes | | `devstack promote --lane ` | the lane's services, dev servers included, answer on the main ports; ask the user first, `--lane main` gives them back. A lane on a node may take them only on a dedicated node (a server) | -| `devstack up --on ` in a worktree | the lane runs on that machine of the pool (`pool`: the coordinator picks one, warm first, `:` in another pool, `local`: here): build, services, its own containers; its ports are forwarded here as if it ran locally. Without `--on` it goes where this machine starts lanes by default (`devstack pool default-on`; here unless the user set it). Ask the user first before starting elsewhere than that default: the worktree's files go to that machine, untracked env files git does not ignore included | +| `devstack up --on ` in a worktree | the lane runs on that machine of the pool (`pool`: the coordinator picks one, warm first, `:` in another pool, `local`: here): build, services, its own containers; its ports are forwarded here as if it ran locally (TCP only: a container's UDP port is not, and `devstack lane list` says so). Without `--on` it goes where this machine starts lanes by default (`devstack pool default-on`; here unless the user set it). Ask the user first before starting elsewhere than that default: the worktree's files go to that machine, untracked env files git does not ignore included | | `devstack pool placement ` (MCP `placement`) | before choosing `--on`: this machine's free CPU and memory, and each node of the pools with its load, free disk, lanes and the coordinator's rank and reason (`keeps this lane's data`, `the repository ran there`, `free capacity`, or why it cannot take it); and the default. Read only | | `devstack pool default-on [pool\|\|local]` | where lanes start without `--on`; setting it is the user's consent to send worktrees there without being asked, so only on the user's word | | `devstack lane move --to ` | move a started lane: a cold start there that takes over once ready; its data comes from the seed jobs again | diff --git a/ui/src/api/types.ts b/ui/src/api/types.ts index dcc99be3..42f27a09 100644 --- a/ui/src/api/types.ts +++ b/ui/src/api/types.ts @@ -158,6 +158,8 @@ export type LaneView = { node_error?: string; /** Its node or the pool's coordinator runs another devstack than this machine, or does not say which. */ node_warning?: string; + /** Of a lane on a node, its containers' published ports this machine does not forward (`5353/udp`): devstack forwards TCP only. Older daemons omit it. */ + not_forwarded?: string[]; /** A start on a node or a move under way (step of steps), or one that failed lately. */ moving?: LaneMove; /** Its worktree is gone: it stops and its data goes (ADR-0024 point 7); it leaves the list after. */ @@ -212,6 +214,8 @@ export type ServiceView = { export type ContainerView = { /** Published ports Docker no longer forwards (accepted, closed at once); older daemons omit it. */ unreachable?: string[]; + /** Of a lane on a node, its published ports of another protocol than TCP (`5353/udp`), which the developer's machine does not reach. Older daemons omit it. */ + not_forwarded?: string[]; service: string; name: string; state: string; diff --git a/ui/src/components/ContainerRow.vue b/ui/src/components/ContainerRow.vue index af3b52f5..c3889a16 100644 --- a/ui/src/components/ContainerRow.vue +++ b/ui/src/components/ContainerRow.vue @@ -4,6 +4,7 @@ import { useRoute, useRouter } from 'vue-router'; import type { ContainerView } from '@/api/types'; import { containerLook, containerRefuses } from '@/lib/status'; import { webUrl } from '@/lib/format'; +import { notForwardedText } from '@/lib/lanes'; import { useStack } from '@/stores/stack'; import StatusPill from './StatusPill.vue'; import Icon from './icons/Icon.vue'; @@ -65,6 +66,7 @@ const extraUrls = computed(() => webUrls.value.filter((u) => !props.container!.p {{ u.replace(/^https?:\/\//, '') }} no published ports not in the stack file + {{ container.not_forwarded.map((p) => p.toUpperCase()).join(', ') }} not forwarded