From 9f771b1cd96ca821304210186bbcb7b7165edbfd Mon Sep 17 00:00:00 2001 From: Sebastian Gieseler Date: Fri, 23 Oct 2026 15:30:45 +0200 Subject: [PATCH 1/2] fix(lanes): a lane carried over a restart is warned about against this release The warning that a lane's node or the coordinator runs another devstack was made when the lane was leased and carried over a restart as a text (ADR-0052). After an update the new daemon still showed "this machine devstack 0.19.0" although every side ran 0.20.0. The daemon now carries the coordinator's release and makes the warning again on adoption. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 11 ++++ crates/devstack-daemon/src/remote.rs | 85 +++++++++++++++++++++++++++- 2 files changed, 93 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f131cbac..7725ceb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,17 @@ and listed with their assets on the ## [Unreleased] +### Fixed + +- **A lane on a node carried over a restart is warned about against the + devstack that runs it now.** The warning that the node or the coordinator + runs another release was made once, when the lane was leased, and carried + over a restart as a text (ADR-0052): after an update to 0.20.0 the lane + still read "the node … runs devstack 0.20.0, this machine devstack + 0.19.0" while every side ran 0.20.0. The daemon now carries the + coordinator's release instead and makes the warning again; a lane carried + by 0.20.0 loses the coordinator's part, which only that daemon knew. + ## [0.20.0] - 2026-10-23 macOS as a developer platform in preview, installed with Homebrew on macOS diff --git a/crates/devstack-daemon/src/remote.rs b/crates/devstack-daemon/src/remote.rs index f6dbf4ff..7b492c9a 100644 --- a/crates/devstack-daemon/src/remote.rs +++ b/crates/devstack-daemon/src/remote.rs @@ -70,6 +70,9 @@ pub struct RemoteLane { pub warning: Option, /// What the node runs, as the lease offer said (`None`: it does not say). node_release: Option, + /// What the coordinator runs, as the lease offer said: carried over a + /// restart, so the next daemon warns against its own release. + coordinator_release: Option, worktree: PathBuf, /// Where `[lanes] sync` files come from when the worktree has none. main: PathBuf, @@ -428,6 +431,7 @@ struct Parts<'a> { node: NodeRef, lease: String, warning: Option, + coordinator: Option, worktree: &'a Path, main: &'a Path, extra: &'a [String], @@ -450,8 +454,12 @@ pub struct Carried { /// before that, whose lane relays none. #[serde(default, skip_serializing_if = "Vec::is_empty")] pub udp_ports: Vec<(u16, u16)>, + /// What the coordinator ran when it granted the lease; absent from a + /// daemon before 0.20.1, which carried its warning as a text. The next + /// daemon makes the warning again against its own release + /// ([`carried_warning`]). #[serde(default, skip_serializing_if = "Option::is_none")] - pub warning: Option, + pub coordinator: Option, } /// Watch `worktree` for changes to sync (ADR-0029 point 2): `dirty` is set @@ -759,6 +767,7 @@ impl RemoteLane { node: offer.node, lease: offer.id, warning, + coordinator: offer.coordinator, worktree, main, extra, @@ -789,6 +798,7 @@ impl RemoteLane { lease: p.lease, warning: p.warning, node_release, + coordinator_release: p.coordinator, worktree: p.worktree.to_path_buf(), main: p.main.to_path_buf(), extra: p.extra.to_vec(), @@ -850,7 +860,7 @@ impl RemoteLane { lease: self.lease.clone(), ports: self.ports.clone(), udp_ports: self.udp_ports.clone(), - warning: self.warning.clone(), + coordinator: self.coordinator_release.clone(), } } @@ -892,6 +902,7 @@ impl RemoteLane { } Err(e) => return Err(format!("renewing its lease on {}: {e}", c.node.name)), }; + let warning = carried_warning(&c); let lane = Self::assemble( rt, Parts { @@ -899,7 +910,8 @@ impl RemoteLane { pool: c.pool, node: c.node, lease: c.lease, - warning: c.warning, + warning, + coordinator: c.coordinator, worktree, main, extra, @@ -1700,6 +1712,23 @@ fn release_warning( Ok((!notes.is_empty()).then(|| notes.join("; "))) } +/// The warning of a lane a daemon before this one followed (ADR-0052), made +/// against this machine's release: the daemon that leased it compared with +/// its own (`this machine devstack 0.19.0` after an update to 0.20.0). The +/// coordinator's release is known from a daemon that carried it (0.20.1). +fn carried_warning(c: &Carried) -> Option { + let node = format!("the node {}", c.node.name); + let notes: Vec = version::note(&node, c.node.devstack.as_ref()) + .into_iter() + .chain( + c.coordinator + .as_ref() + .and_then(|r| version::note("the coordinator", Some(r))), + ) + .collect(); + (!notes.is_empty()).then(|| notes.join("; ")) +} + /// Did a connection of a tunnel end because one end hung up (reset, aborted, /// a write to a closed socket)? Windows says "aborted" (10053) where a /// browser closes a connection it kept alive. @@ -2086,4 +2115,54 @@ members = ["api"] serde_json::from_str(&serde_json::to_string(&c).unwrap()).unwrap(); assert_eq!(again.udp_ports, [(5453, 5453)]); } + + #[test] + fn a_lane_carried_over_is_warned_about_against_this_release() { + use super::carried_warning; + let this = Release::this(); + let older = Release { + version: "0.0.1".into(), + ..this.clone() + }; + // A 0.20.0 daemon carried the text its 0.19.0 predecessor made; the + // node and the coordinator run this release by now. + let c: super::Carried = serde_json::from_str(&format!( + r#"{{"pool":"default","lease":"l1","ports":[], + "node":{{"id":"n1","name":"build-1","api":"https://n", + "devstack":{{"version":"{v}","protocol":{p}}}}}, + "warning":"the node build-1 runs devstack {v}, this machine devstack 0.0.1"}}"#, + v = this.version, + p = this.protocol + )) + .unwrap(); + assert_eq!(carried_warning(&c), None, "the same release everywhere"); + let c = super::Carried { + coordinator: Some(older.clone()), + ..c + }; + let w = carried_warning(&c).unwrap(); + assert!( + w.starts_with("the coordinator runs devstack 0.0.1") && w.contains(version::VERSION), + "{w}" + ); + let c = super::Carried { + node: NodeRef { + devstack: None, + ..c.node + }, + coordinator: Some(this), + ..c + }; + let w = carried_warning(&c).unwrap(); + assert!(w.contains("build-1") && w.contains("does not say"), "{w}"); + let again: super::Carried = serde_json::from_str( + &serde_json::to_string(&super::Carried { + coordinator: Some(older.clone()), + ..c + }) + .unwrap(), + ) + .unwrap(); + assert_eq!(again.coordinator, Some(older)); + } } From dc11087a45bf3912282a7a2eb19bfb364713bed5 Mon Sep 17 00:00:00 2001 From: 7schmiede Date: Fri, 23 Oct 2026 22:26:07 +0200 Subject: [PATCH 2/2] test(daemon): wait for the killed daemon to go before `up` in the stop test `a_services_stop_ends_what_its_run_started` ran `up` right after `kill -9`; `up` could still reach the dying daemon and fail with a reset connection (integration, ubuntu-latest). It now waits until the daemon's port no longer answers, as the lifecycle test does after its hard kill. Co-Authored-By: Claude Opus 5.5 --- crates/devstack/tests/daemon_lifecycle.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/devstack/tests/daemon_lifecycle.rs b/crates/devstack/tests/daemon_lifecycle.rs index fb939a76..54b312d0 100644 --- a/crates/devstack/tests/daemon_lifecycle.rs +++ b/crates/devstack/tests/daemon_lifecycle.rs @@ -296,6 +296,14 @@ members = [\"api\", \"command.ping\"] serde_json::from_str(&self.api("/info").expect("api answers /info")).unwrap() } + fn daemon_port(&self) -> u16 { + let info: Value = serde_json::from_slice( + &std::fs::read(self.dir.path().join(".devstack/daemon.json")).unwrap(), + ) + .unwrap(); + info["port"].as_u64().unwrap() as u16 + } + fn daemon_pid(&self) -> u32 { let info: Value = serde_json::from_slice( &std::fs::read(self.dir.path().join(".devstack/daemon.json")).unwrap(), @@ -1605,7 +1613,16 @@ port = {port} s.ok(&["start", "box"]); let second = instance_port(); assert!(second != 0 && second != first, "{}", s.diag()); + let daemon_port = s.daemon_port(); kill_hard(s.daemon_pid()); + // Until it is gone, `up` may still reach the dying daemon. + assert!( + wait_for( + || std::net::TcpStream::connect(("127.0.0.1", daemon_port)).is_err(), + Duration::from_secs(10) + ), + "the daemon survived its kill" + ); s.ok(&["up"]); assert!( stops().contains(&format!("stopped-{second}")),