Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,28 @@ and listed with their assets on the

## [Unreleased]

### Changed

- **`singleton = true` replaces `lanes = false`** (ADR-0080): a service that
runs once per machine, in the main working tree only. `lanes = false`
still works and means the same; `devstack check` reports it as
deprecated.

### Deprecated

- **`[compose.<group>] shared`** (ADR-0080): it works as before, and
`devstack check` and `devstack doctor` report it; it goes with
`version = 2`. It ties a lane to the main tree, reaches only native
services (a lane's containers do not find it by name), behaves
differently for a lane on a node, and mixes the lanes' telemetry. Drop
it: every lane starts its own containers; a profile's `skip` leaves out
what a lane can do without.

### Added

- **`/v1/lanes/main/v1/...`** answers as the main working tree's `/v1/...`
(ADR-0080), so a client addresses every tree as a lane.

## [0.32.0] - 2026-10-30

A pool's project skills stay in their repository: a skill bound with
Expand Down
32 changes: 28 additions & 4 deletions crates/devstack-config/src/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
//! A key that is renamed or removed stays readable for a while: the model keeps
//! accepting it (`#[serde(alias = "...")]`, or an optional field that is no
//! longer used), and it is listed in [`DEPRECATED`], so `devstack check` and
//! `devstack doctor` say what replaces it. The table is empty until the first
//! such change.
//! `devstack doctor` say what replaces it.

use crate::validate::Issue;

Expand All @@ -18,7 +17,18 @@ pub struct Deprecation {
pub since: &'static str,
}

pub const DEPRECATED: &[Deprecation] = &[];
pub const DEPRECATED: &[Deprecation] = &[
Deprecation {
path: "services.*.lanes",
replacement: "`singleton = true` (ADR-0080)",
since: "0.33.0",
},
Deprecation {
path: "compose.*.shared",
replacement: "each lane's own containers: drop the key; a profile's `skip` leaves containers out (ADR-0080)",
since: "0.33.0",
},
];

/// Warnings for deprecated keys in a stack file's text (never errors).
pub fn warnings(text: &str) -> Vec<Issue> {
Expand Down Expand Up @@ -91,7 +101,21 @@ mod tests {
}

#[test]
fn nothing_is_deprecated_yet() {
fn lanes_false_is_deprecated_for_singleton() {
assert!(warnings("version = 1\n[stack]\nname = \"x\"\n").is_empty());
let w = warnings("version = 1\n[services.tray]\nrun = \"x\"\nlanes = false\n");
assert_eq!(w.len(), 1);
assert_eq!(w[0].path, "services.tray.lanes");
assert!(w[0].message.contains("singleton"), "{}", w[0].message);
}

#[test]
fn shared_is_deprecated() {
let w = warnings(
"version = 1\n[compose.app]\nfiles = [\"c.yml\"]\nservices = [\"mail\"]\nshared = [\"mail\"]\n",
);
assert_eq!(w.len(), 1);
assert_eq!(w[0].path, "compose.app.shared");
assert!(w[0].message.contains("own containers"), "{}", w[0].message);
}
}
23 changes: 17 additions & 6 deletions crates/devstack-config/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -941,12 +941,17 @@ pub struct Service {
/// Restrict to these platforms; empty = all.
#[serde(default)]
pub platforms: Vec<Platform>,
/// `false`: runs in the main working tree only, never in a lane
/// (ADR-0024). For what may run once per machine (a tray app, something
/// that holds a global lock); the main tree's instance serves every lane
/// and keeps its workers while a lane holds the main slot.
#[serde(default = "yes")]
pub lanes: bool,
/// `true`: runs once per machine, in the main working tree only, never in
/// a lane (ADR-0024, ADR-0080). For a tray app or something that holds a
/// global lock; the main tree's instance serves every lane and keeps its
/// workers while a lane holds the main slot. Read through
/// [`Service::singleton`].
#[serde(default)]
pub singleton: bool,
/// `lanes = false`: the spelling of `singleton = true` before 0.33.0
/// (deprecated, `compat::DEPRECATED`).
#[serde(default = "yes", rename = "lanes")]
pub legacy_lanes: bool,
/// Compose service whose environment is the base (ADR-0014).
pub compose: Option<ComposeRef>,
/// Compose services whose `name:port` is rewritten to the published host
Expand Down Expand Up @@ -1258,6 +1263,12 @@ fn opt_duration<'de, D: serde::Deserializer<'de>>(d: D) -> Result<Option<Duratio
}

impl Service {
/// Runs once per machine, in the main working tree only (`singleton =
/// true`, or the older `lanes = false`).
pub fn singleton(&self) -> bool {
self.singleton || !self.legacy_lanes
}

/// `https` when the health check speaks TLS (a dev server with a
/// certificate), otherwise `http`: how a browser or a command reaches the
/// service on its fixed port.
Expand Down
2 changes: 1 addition & 1 deletion crates/devstack-config/src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ pub fn warnings(stack: &Stack) -> Vec<Issue> {
pub fn repo_warnings(stack: &Stack, repo: &std::path::Path) -> Vec<Issue> {
let mut out = Vec::new();
for (name, svc) in &stack.services {
if svc.kind != Kind::Devserver || !svc.lanes || svc.prepare.is_some() {
if svc.kind != Kind::Devserver || svc.singleton() || svc.prepare.is_some() {
continue;
}
let cwd = svc.cwd.as_deref().unwrap_or(".");
Expand Down
19 changes: 18 additions & 1 deletion crates/devstack-config/tests/stack_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ fn a_dev_server_with_a_package_json_and_no_prepare_is_a_warning() {
"port = 5173\nprepare = { run = \"npm ci\" }\n",
);
assert!(warnings(&prepared).is_empty());
let main_only = text.replace("port = 5173\n", "port = 5173\nlanes = false\n");
let main_only = text.replace("port = 5173\n", "port = 5173\nsingleton = true\n");
assert!(warnings(&main_only).is_empty());
assert!(warnings(&text.replace("cwd = \"web\"", "cwd = \"api\"")).is_empty());
}
Expand Down Expand Up @@ -1238,3 +1238,20 @@ fn a_services_stop_takes_the_placeholders_of_its_run() {
"{all}"
);
}

#[test]
fn singleton_and_the_older_lanes_false_mean_the_same() {
let svc = |extra: &str| {
let s = from_str(
&format!("{MINIMAL}[services.tray]\nrun = \"x\"\n{extra}"),
Path::new("t"),
)
.unwrap();
s.services["tray"].singleton()
};
assert!(!svc(""));
assert!(svc("singleton = true\n"));
assert!(svc("lanes = false\n"));
assert!(!svc("lanes = true\n"));
assert!(!svc("singleton = false\n"));
}
40 changes: 38 additions & 2 deletions crates/devstack-daemon/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,42 @@ pub struct AppState {
}

pub fn router(state: AppState) -> axum::Router {
let main_tree = state.lanes.is_some();
let app = routes(state);
if !main_tree {
return app;
}
// The main working tree is the lane `main` too (ADR-0080):
// `/v1/lanes/main/v1/...` is its `/v1/...`, so a client can address
// every tree the same way.
let inner = app.clone();
app.route(
"/v1/lanes/main/v1/{*rest}",
axum::routing::any(move |req: Request| {
use tower::ServiceExt;
let inner = inner.clone();
async move {
let (mut parts, body) = req.into_parts();
let path = parts.uri.path().replacen("/v1/lanes/main", "", 1);
let query = parts
.uri
.query()
.map(|q| format!("?{q}"))
.unwrap_or_default();
let Ok(uri) = format!("{path}{query}").parse() else {
return err(StatusCode::BAD_REQUEST, "bad path");
};
parts.uri = uri;
match inner.oneshot(Request::from_parts(parts, body)).await {
Ok(r) => r,
Err(e) => match e {},
}
}
}),
)
}

fn routes(state: AppState) -> axum::Router {
axum::Router::new()
.route("/v1/stack", get(stack))
.route("/v1/journal", get(journal))
Expand Down Expand Up @@ -308,7 +344,7 @@ struct DownQuery {
/// `204` once every service (and with `infra`, the default, every Compose
/// group) stopped; `409` naming what did not. In the main tree, lanes that
/// still run keep the daemon they live in (ADR-0024), what serves them
/// (`lanes = false`, and the containers it comes `after`) and, a lane here,
/// (`singleton`, and the containers it comes `after`) and, a lane here,
/// the `shared` containers (ADR-0030): then `200` with `{"lanes": [...],
/// "kept": [...], "containers": [...]}`; every other container goes
/// (ADR-0068). With `all` the lanes stop first (`Lanes::stop_all`).
Expand All @@ -326,7 +362,7 @@ async fn down(State(s): State<AppState>, Query(q): Query<DownQuery>) -> Response
let local = s.lanes.as_ref().is_some_and(|l| l.any_local());
let infra = q.infra;
let sup = s.sup.clone();
// Lanes that still run keep what serves them (`lanes = false`).
// Lanes that still run keep what serves them (`singleton`).
let keeping = !lanes.is_empty() && s.lanes.is_some();
let result = tokio::task::spawn_blocking(move || {
if keeping {
Expand Down
8 changes: 4 additions & 4 deletions crates/devstack-daemon/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl Resolve for CommandContext {
}

/// A `start`, `stop` or `restart` step on a service that runs in the main
/// working tree only (`lanes = false`) has nothing to act on in a lane: the
/// working tree only (`singleton`) has nothing to act on in a lane: the
/// main tree's instance serves it. The step is skipped, and the run's log
/// says why, as `after` skips such a service: a command written for both
/// trees does not end as failed in a lane after everything it needed ran.
Expand All @@ -147,9 +147,9 @@ fn main_tree_only(
else {
return None;
};
(!lane.is_empty() && stack.services.get(*name).is_some_and(|s| !s.lanes)).then(|| {
(!lane.is_empty() && stack.services.get(*name).is_some_and(|s| s.singleton())).then(|| {
format!(
"`{name}` runs in the main working tree only (`lanes = false`); its instance there serves this lane"
"`{name}` runs in the main working tree only (`singleton`); its instance there serves this lane"
)
})
}
Expand Down Expand Up @@ -433,7 +433,7 @@ services = ["db"]
run = "x"
[services.worker]
run = "x"
lanes = false
singleton = true
"#;

fn stack() -> devstack_config::Stack {
Expand Down
2 changes: 1 addition & 1 deletion crates/devstack-daemon/src/lanes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3473,7 +3473,7 @@ impl Lanes {
.iter()
.filter(|(_, s)| {
s.autostart
&& s.lanes
&& !s.singleton()
&& (s.platforms.is_empty()
|| s.platforms
.contains(&devstack_config::model::Platform::Linux))
Expand Down
12 changes: 6 additions & 6 deletions crates/devstack-daemon/src/supervisor/handover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl Supervisor {
self.stack
.services
.iter()
.filter(|(_, s)| s.proxied() && s.lanes && self.runs_here(s))
.filter(|(_, s)| s.proxied() && !s.singleton() && self.runs_here(s))
.map(|(n, _)| n.clone())
.collect()
}
Expand All @@ -96,7 +96,7 @@ impl Supervisor {
s.port.is_some()
&& !s.proxied()
&& s.kind != Kind::Job
&& s.lanes
&& !s.singleton()
&& self.runs_here(s)
})
.map(|(n, _)| n.clone())
Expand Down Expand Up @@ -160,9 +160,9 @@ impl Supervisor {
self.stack
.services
.iter()
// `lanes = false` keeps its workers wherever the main slot is.
// A `singleton` keeps its workers wherever the main slot is.
.filter(|(n, s)| {
s.workers.is_some() && s.lanes && slots[n.as_str()].view.status.is_active()
s.workers.is_some() && !s.singleton() && slots[n.as_str()].view.status.is_active()
})
.map(|(n, _)| n.clone())
.collect()
Expand Down Expand Up @@ -229,7 +229,7 @@ impl Supervisor {
/// such containers only has nothing to move (#184).
pub(crate) fn moves_main_slot(stack: &devstack_config::Stack) -> bool {
stack.services.values().any(|s| {
s.lanes
!s.singleton()
&& super::on_this_platform(s)
&& ((s.port.is_some() && s.kind != Kind::Job) || s.workers.is_some())
}) || stack.compose.values().any(|g| !g.main_ports.is_empty())
Expand Down Expand Up @@ -258,7 +258,7 @@ name = \"s\"
"[services.once]
run = \"x\"
port = 9001
lanes = false
singleton = true
"
)));
}
Expand Down
10 changes: 6 additions & 4 deletions crates/devstack-daemon/src/supervisor/lifecycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ impl Supervisor {
}

/// Main tree, while lanes run: stop every service but those that serve
/// the lanes, a service with `lanes = false` and what it starts `after`
/// the lanes, a `singleton` service and what it starts `after`
/// (ADR-0024 point 5: the main tree's instance serves every lane). With
/// `infra` the containers go too (ADR-0068), but those a kept service
/// comes `after` and, while `local_lanes`, the `shared` ones (a lane
Expand All @@ -284,7 +284,7 @@ impl Supervisor {
.stack
.services
.iter()
.filter(|(_, s)| !s.lanes)
.filter(|(_, s)| s.singleton())
.map(|(n, _)| n.clone())
.collect();
let mut containers: BTreeSet<(String, String)> = BTreeSet::new();
Expand Down Expand Up @@ -552,7 +552,7 @@ impl Supervisor {
}
if !self.runs_here(&svc) {
return Err(format!(
"`{name}` runs in the main working tree only (`lanes = false`); its instance there serves this lane too"
"`{name}` runs in the main working tree only (`singleton`); its instance there serves this lane too"
));
}
if let Err(e) = self.ensure_after(&svc) {
Expand Down Expand Up @@ -990,7 +990,9 @@ impl Supervisor {
// A lane without the main slot never runs workers (ADR-0012 interim rule).
// What runs in the main tree only keeps its workers: no lane takes them over.
is_main: is_main
&& (self.owns_main() || !svc.lanes || self.lane_workers.load(Ordering::SeqCst)),
&& (self.owns_main()
|| svc.singleton()
|| self.lane_workers.load(Ordering::SeqCst)),
// The slot, not the workers: a lane's main instance is no candidate.
candidate: !is_main,
// `{lane}`, `{lane_suffix}`, `DEVSTACK_LANE`: on a node the lane's
Expand Down
4 changes: 2 additions & 2 deletions crates/devstack-daemon/src/supervisor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -980,9 +980,9 @@ impl Supervisor {
}

/// `svc` runs in this supervisor: on this platform, and in a lane only
/// unless it says `lanes = false`.
/// unless it is a `singleton`.
fn runs_here(&self, svc: &Service) -> bool {
on_this_platform(svc) && (self.lane.is_empty() || svc.lanes)
on_this_platform(svc) && (self.lane.is_empty() || !svc.singleton())
}

/// Run `action` once the changes for `key` have been quiet for a moment.
Expand Down
2 changes: 1 addition & 1 deletion crates/devstack-daemon/src/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ fn watch(sup: Arc<Supervisor>) -> Result<Watcher, String> {
let platform = devstack_config::model::Platform::current();
let in_lane = !sup.lane.is_empty();
let runs = |s: &devstack_config::model::Service| {
(s.platforms.is_empty() || s.platforms.contains(&platform)) && (!in_lane || s.lanes)
(s.platforms.is_empty() || s.platforms.contains(&platform)) && (!in_lane || !s.singleton())
};
let built: Vec<(String, GlobSet)> = sup
.stack
Expand Down
4 changes: 2 additions & 2 deletions crates/devstack/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ pub fn start_and_wait(
&& (s.platforms.is_empty()
|| s.platforms
.contains(&devstack_config::model::Platform::current()))
&& (c.lane().is_none() || s.lanes)
&& (c.lane().is_none() || !s.singleton())
})
.map(|(n, _)| n.clone())
.collect();
Expand Down Expand Up @@ -2412,7 +2412,7 @@ pub fn down(stack_file: &Path, infra: bool, all: bool) -> Result<()> {
.and_then(|v| serde_json::from_value(v[key].clone()).ok())
.unwrap_or_default()
};
// What serves the lanes (`lanes = false`) runs on for them.
// What serves the lanes (`singleton`) runs on for them.
let kept = list("kept");
let containers = list("containers");
let mut stays = vec!["the daemon".to_string()];
Expand Down
Loading