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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ and listed with their assets on the

## [Unreleased]

### Fixed

- **A long-running job no longer reads as "starting" for its whole run**
(#611). In a stack's overview a job that runs is in a state of its own
("running as a job"), counted neither as healthy nor as starting, with
its own filter. On the start page a stack with a running job is
"Running · 1 job" instead of "Starting", and a stack whose main tree is
stopped while a lane runs shows the lanes' services ("Services in
lanes 1/4") instead of 0/4. The hub's summary (`GET /hub/summary`, the
`summary` event) carries `jobs`, `lane_ready` and `lane_total` for it;
a running job no longer makes a stack `starting`.

## [0.52.0] - 2026-11-21

A shared machine keeps the GPUs its owner wants: the share switch takes a
Expand Down
17 changes: 10 additions & 7 deletions crates/devstack-hub/src/notify/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,9 @@ impl Scope {
for name in names {
let svc = &self.services[name];
match svc.state.as_str() {
// A job runs until it ends (#544): that is its start (#575).
"running" if svc.kind == "job" => g.starting = true,
// A job runs until it ends (#544): not ready (#575), and not
// a start either, which a run of hours would show (#611).
"running" if svc.kind == "job" => g.jobs += 1,
"running" | "healthy" => g.ready += 1,
"completed" if svc.exit_code == Some(0) => g.ready += 1,
"building" | "starting" => g.starting = true,
Expand Down Expand Up @@ -530,25 +531,27 @@ mod tests {
assert_eq!(g.attention[1].level, Level::Error);
}

/// #575: a job is `running` while it runs (#544), which is its start,
/// not a service that is ready; a long-running service's `running` is.
/// #575: a job is `running` while it runs (#544), not a service that is
/// ready; a long-running service's `running` is. #611: nor is it a start,
/// which a training of hours would show for its whole run.
#[test]
fn a_running_job_counts_as_starting_not_ready() {
fn a_running_job_counts_as_a_job_not_ready_nor_starting() {
let mut s = Scope::default();
s.apply(&snapshot(json!([
{ "name": "api", "kind": "long-running", "status": { "state": "running" } },
{ "name": "migrate", "kind": "job", "status": { "state": "starting" } }
])));
assert_eq!((s.glance().starting, s.glance().jobs), (true, 0));
// The service event carries no kind: the snapshot's stays.
s.apply(&service("migrate", json!({ "state": "running" })));
let g = s.glance();
assert_eq!((g.ready, g.total, g.starting), (1, 2, true));
assert_eq!((g.ready, g.total, g.starting, g.jobs), (1, 2, false, 1));
s.apply(&service(
"migrate",
json!({ "state": "completed", "exit_code": 0 }),
));
let g = s.glance();
assert_eq!((g.ready, g.starting), (2, false));
assert_eq!((g.ready, g.starting, g.jobs), (2, false, 0));
}

#[test]
Expand Down
62 changes: 61 additions & 1 deletion crates/devstack-hub/src/summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ pub(crate) struct Glance {
pub total: usize,
/// A service builds or starts.
pub starting: bool,
/// Jobs running (#611): neither ready nor starting.
pub jobs: usize,
pub attention: Vec<Item>,
}

Expand Down Expand Up @@ -145,6 +147,12 @@ pub(crate) struct StackSummary {
pub total: usize,
/// Lanes whose stream the hub follows: started, here or on a node.
pub lanes: usize,
/// Jobs running in the main tree and the lanes (#611).
pub jobs: usize,
/// The lanes' services ready, of all, summed (#611): a stack that works
/// in a lane while its main tree is stopped does not look idle.
pub lane_ready: usize,
pub lane_total: usize,
pub attention: Vec<Item>,
}

Expand Down Expand Up @@ -180,9 +188,15 @@ fn stack(
});
}
let mut starting = false;
let (mut jobs, mut lane_ready, mut lane_total) = (0, 0, 0);
for (lane, g) in streams {
if e.running {
starting |= g.starting;
jobs += g.jobs;
if lane.is_some() {
lane_ready += g.ready;
lane_total += g.total;
}
attention.extend(g.attention.iter().cloned().map(|mut i| {
i.lane = lane.clone();
i
Expand All @@ -206,6 +220,9 @@ fn stack(
ready: main.ready,
total: main.total,
lanes: streams.keys().filter(|l| l.is_some()).count(),
jobs,
lane_ready,
lane_total,
attention,
}
}
Expand Down Expand Up @@ -274,6 +291,9 @@ pub(crate) struct StackGlance {
pub ready: usize,
pub total: usize,
pub lanes: usize,
pub jobs: usize,
pub lane_ready: usize,
pub lane_total: usize,
}

/// Every stack's figures in `sum`, for `/hub/events`.
Expand All @@ -286,6 +306,9 @@ pub(crate) fn glances(sum: &Summary) -> Vec<StackGlance> {
ready: st.ready,
total: st.total,
lanes: st.lanes,
jobs: st.jobs,
lane_ready: st.lane_ready,
lane_total: st.lane_total,
})
.collect()
}
Expand Down Expand Up @@ -345,6 +368,39 @@ mod tests {
assert_eq!(overall(&[s]), "attention");
}

/// #611: a job running for hours in a lane, while the main tree is
/// stopped, is neither a start nor an idle stack.
#[test]
fn a_running_job_is_counted_and_the_lanes_have_their_figures() {
let streams = BTreeMap::from([
(
None,
Glance {
total: 4,
..Default::default()
},
),
(
Some("run-8".to_string()),
Glance {
ready: 1,
total: 4,
jobs: 1,
..Default::default()
},
),
]);
let s = stack(&entry("ab12", true), None, &streams);
assert_eq!(s.state, "ok");
assert_eq!(
(s.ready, s.total, s.jobs, s.lane_ready, s.lane_total),
(0, 4, 1, 1, 4)
);
// A stopped stack's stale streams count nothing.
let s = stack(&entry("ab12", false), None, &streams);
assert_eq!((s.jobs, s.lane_ready, s.lane_total), (0, 0, 0));
}

#[test]
fn a_stopped_stack_shows_its_failed_start_and_nothing_stale() {
let mut e = entry("ab12", false);
Expand Down Expand Up @@ -427,11 +483,15 @@ mod tests {
ready: 2,
total: 3,
lanes: 1,
jobs: 1,
lane_ready: 1,
lane_total: 4,
})
.unwrap();
assert_eq!(
v,
serde_json::json!({ "id": "ab12", "state": "ok", "ready": 2, "total": 3, "lanes": 1 })
serde_json::json!({ "id": "ab12", "state": "ok", "ready": 2, "total": 3, "lanes": 1,
"jobs": 1, "lane_ready": 1, "lane_total": 4 })
);
}

Expand Down
4 changes: 2 additions & 2 deletions docs/dashboard-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ and `Referrer-Policy: no-referrer`. The dashboard has no inline script.
| `POST /hub/notify/test` | cookie + Origin | one notification whatever the settings say: `204`, or `503` with why nothing shows. A click opens the dashboard |
| `GET /hub/session` | cookie | `200 {"version": "<x.y.z>", "link_unavailable": string\|null}`, or `401` (not paired: show "run `devstack ui`"). `link_unavailable` says why this platform has no `devstack://` link (macOS: "not on macOS yet", ADR-0054): the page keeps it and offers `devstack hub start` instead of its "Start hub" link while the hub is down. Older hubs leave it out |
| `GET /hub/stacks` | cookie | `[StackEntry]` |
| `GET /hub/summary` | cookie or token | every registered stack at a glance, for the tray ([ADR-0060](adr/0060-the-tray-is-a-client-of-the-hub.md)): `{"state", "version", "stacks": [{id, name, repo, running, state, ready, total, lanes, attention: [{lane, service, text, detail}]}]}`. A stack's `state`: `stopped`, `starting`, `stopping` (a start or stop the hub runs), `ok` or `attention`; the whole `state` is the worst: `attention`, `starting`, `ok` (a stack runs) or `idle`. `ready` of `total`: the main tree's services running, healthy or done. `lanes`: started lanes. `attention`: what notifies (ADR-0045) and is still so, in the main tree and every started lane (`lane` names it): a failed service (not one the user stopped, not one held back by another's failure), a candidate `held` or whose build `failed`, a lane whose start or move on a node failed (`service` `null`); and a failed start from the dashboard (`service` `null`). Each item's `level` ([ADR-0097](adr/0097-the-dashboards-mark-says-what-needs-attention.md)): `warn` for a candidate held, `error` for the rest; older hubs leave it out. Containers are not in it. `version`: the hub's devstack |
| `GET /hub/summary` | cookie or token | every registered stack at a glance, for the tray ([ADR-0060](adr/0060-the-tray-is-a-client-of-the-hub.md)): `{"state", "version", "stacks": [{id, name, repo, running, state, ready, total, lanes, jobs, lane_ready, lane_total, attention: [{lane, service, text, detail}]}]}`. A stack's `state`: `stopped`, `starting`, `stopping` (a start or stop the hub runs), `ok` or `attention`; the whole `state` is the worst: `attention`, `starting`, `ok` (a stack runs) or `idle`. `ready` of `total`: the main tree's services running, healthy or done; a job that still runs is not ready, and does not make the stack `starting` either. `lanes`: started lanes. `jobs`: jobs running, in the main tree and the started lanes. `lane_ready` of `lane_total`: the started lanes' services, summed (the start page shows them while nothing of the main tree is up). Older hubs leave the last three out. `attention`: what notifies (ADR-0045) and is still so, in the main tree and every started lane (`lane` names it): a failed service (not one the user stopped, not one held back by another's failure), a candidate `held` or whose build `failed`, a lane whose start or move on a node failed (`service` `null`); and a failed start from the dashboard (`service` `null`). Each item's `level` ([ADR-0097](adr/0097-the-dashboards-mark-says-what-needs-attention.md)): `warn` for a candidate held, `error` for the rest; older hubs leave it out. Containers are not in it. `version`: the hub's devstack |
| `GET /hub/ports` | cookie or token | the ports of every registered stack on this machine and where two stacks meet ([ADR-0082](adr/0082-the-ports-of-a-machine.md)): `{"stacks": [{id, name, running, containers?, ports: [PortEntry]}], "overlaps": [{port, proto, stacks: [{id, name, lane, holder?, kind}]}]}`. A running stack's `ports` are its daemon's `GET /v1/ports` (see [Ports](#ports)); a stack whose daemon does not run, or does not answer it (an older devstack), has what its stack file declares for the main working tree, each `kind: "declared"`, `lane: "main"`, moved by its shift on this machine: its services' `port`, its Compose groups' `announced_ports` and the ports on this machine their `urls` name (other published ports of the Compose files are not read). What a stopped stack's containers publish that run all the same (Docker started them again by their restart policy, or a stop kept them) is asked of Docker: those ports are `kind: "published"`, `listening: true`, in place of a declared entry of the same port, and the stack has `containers: true` ([ADR-0096](adr/0096-a-port-held-now-refuses-the-start-one-up-of-a-tree-at-a-time.md)). A stopped stack whose stack file is gone is left out; one whose file does not load has no ports. An overlap is one `port` and `proto` in more than one stack, each use listed once; an `instance` port does not count (the OS hands it out). Computed on request, nothing is polled |
| `GET /hub/ws?path=<stream>` | cookie + Origin | WebSocket that carries the server-sent event stream at `<stream>` (`/hub/events`, `/hub/stacks/{id}/api/v1/...`, or `/hub/pool/shared/{lease}/api/v1/...[?pool=]` for a lane shared with this machine), one text message per event's `data`; how the dashboard reads every stream (a browser allows six HTTP/1.1 connections per host across all its tabs, WebSockets do not count; ADR-0021). The upstream is opened before the upgrade: `503` for a stack not running, `400` for another path. When the stream ends the socket closes |
| `GET /hub/events` | cookie | SSE: `{"type":"stacks","stacks":[StackEntry]}` and `{"type":"docker","docker":DockerEngine}` and `{"type":"release","current","newer":string|null,"error":string|null}` (a newer devstack; checked at start, every 12 h by the clock and when a dashboard connects and the last answer is over an hour old, unless `DEVSTACK_NO_UPDATE_CHECK`; `error` why the last check failed, no network or GitHub's rate limit, tried again after an hour and `null` once one succeeds, while a `newer` found before stays; older hubs leave it out) and `{"type":"update","update":{"running":bool,"error":string|null,"installed":string|null,"finished":ms|null}}` (the dashboard's update; `finished` is when the last one ended, `installed` the version it installed, told by the hub it started) and `{"type":"guests","guests":[Guest]}` (lanes of other members on this machine, every pool: `{pool, lease, member, owner, repo, lane, state: "offered"\|"running", since: unix s, cpus, memory}`, the leases whose node is this machine; read when the pool's stream says its leases or nodes changed) and `{"type":"worktrees","worktrees":{"<stack id>":"<version>"}}` (a version of each registered stack's worktrees, running or not, ADR-0078: the hub looks at their folder once a second; a stack's lanes are read again when its version changes; older hubs never send it. Since ADR-0088 the version also moves when a checked-out branch or its upstream moves: their loose ref files, `packed-refs` and `FETCH_HEAD`, looked at without running git; the dashboard reads `branches` again then) and `{"type":"activity","at":ms}` (a record was added to the agents' activity, [ADR-0098](adr/0098-the-skills-page-shows-the-flow-of-the-hooks-and-the-agents-activity.md): read `/hub/activity` again; looked at every two seconds while a dashboard listens; older hubs never send it) and `{"type":"attention","items":[{stack, lane, service, text, detail, level}]}` (what needs attention in every stack, the items of `/hub/summary` with their stack's id, [ADR-0097](adr/0097-the-dashboards-mark-says-what-needs-attention.md): sent again when one changed; the dashboard's dot on its mark and favicon; older hubs never send it) and `{"type":"summary","stacks":[{id, state, ready, total, lanes}]}` (every stack's figures for the dashboard's start page, [ADR-0104](adr/0104-the-start-page-shows-every-stack-as-a-tile.md): `/hub/summary`'s stacks without their attention items; sent again when one changed; a start or stop the hub runs shows only once the daemon came or went; older hubs never send it) and `{"type":"pools","pools":{"<pool>":{"live":"connecting"\|"live"\|"lost"\|"old","error"?,"versions":{"members","nodes","leases","upstreams","telemetry"}}}}` (the pools this machine follows over their coordinators' streams, ADR-0073: `old` for a coordinator without one, whose parts are read when the pool area opens; `versions` of each part, read again when one is not the one read last; older hubs never send it), each first and on every change |
| `GET /hub/events` | cookie | SSE: `{"type":"stacks","stacks":[StackEntry]}` and `{"type":"docker","docker":DockerEngine}` and `{"type":"release","current","newer":string|null,"error":string|null}` (a newer devstack; checked at start, every 12 h by the clock and when a dashboard connects and the last answer is over an hour old, unless `DEVSTACK_NO_UPDATE_CHECK`; `error` why the last check failed, no network or GitHub's rate limit, tried again after an hour and `null` once one succeeds, while a `newer` found before stays; older hubs leave it out) and `{"type":"update","update":{"running":bool,"error":string|null,"installed":string|null,"finished":ms|null}}` (the dashboard's update; `finished` is when the last one ended, `installed` the version it installed, told by the hub it started) and `{"type":"guests","guests":[Guest]}` (lanes of other members on this machine, every pool: `{pool, lease, member, owner, repo, lane, state: "offered"\|"running", since: unix s, cpus, memory}`, the leases whose node is this machine; read when the pool's stream says its leases or nodes changed) and `{"type":"worktrees","worktrees":{"<stack id>":"<version>"}}` (a version of each registered stack's worktrees, running or not, ADR-0078: the hub looks at their folder once a second; a stack's lanes are read again when its version changes; older hubs never send it. Since ADR-0088 the version also moves when a checked-out branch or its upstream moves: their loose ref files, `packed-refs` and `FETCH_HEAD`, looked at without running git; the dashboard reads `branches` again then) and `{"type":"activity","at":ms}` (a record was added to the agents' activity, [ADR-0098](adr/0098-the-skills-page-shows-the-flow-of-the-hooks-and-the-agents-activity.md): read `/hub/activity` again; looked at every two seconds while a dashboard listens; older hubs never send it) and `{"type":"attention","items":[{stack, lane, service, text, detail, level}]}` (what needs attention in every stack, the items of `/hub/summary` with their stack's id, [ADR-0097](adr/0097-the-dashboards-mark-says-what-needs-attention.md): sent again when one changed; the dashboard's dot on its mark and favicon; older hubs never send it) and `{"type":"summary","stacks":[{id, state, ready, total, lanes, jobs, lane_ready, lane_total}]}` (every stack's figures for the dashboard's start page, [ADR-0104](adr/0104-the-start-page-shows-every-stack-as-a-tile.md): `/hub/summary`'s stacks without their attention items; sent again when one changed; a start or stop the hub runs shows only once the daemon came or went; older hubs never send it) and `{"type":"pools","pools":{"<pool>":{"live":"connecting"\|"live"\|"lost"\|"old","error"?,"versions":{"members","nodes","leases","upstreams","telemetry"}}}}` (the pools this machine follows over their coordinators' streams, ADR-0073: `old` for a coordinator without one, whose parts are read when the pool area opens; `versions` of each part, read again when one is not the one read last; older hubs never send it), each first and on every change |
| `POST /hub/update` | cookie + Origin | `202`: `devstack update` in the background (output in `hub/update.log`); on success it restarts the hub on the new version, so the dashboard reconnects to it, and the new hub's `update` event names the installed version (the old hub leaves `hub/update.json` for it; a hub that starts on the old version while the updater runs waits for it and reports a failure); on failure the `update` event carries the end of its output. `409` while one runs (checked and claimed in one step). Running stacks switch at their next restart |
| `POST /hub/update/check` | cookie + Origin | look for a newer release now: `{"current", "newer": string\|null}`, the same as the next `release` event; asked again within 30 s, the last answer (GitHub allows 60 unauthenticated requests an hour), and the last answer too while GitHub's rate limit lasts (its error names the time it ends). `409` with `DEVSTACK_NO_UPDATE_CHECK`, `502` when GitHub cannot be asked, `504` after 30 s |
| `POST /hub/stacks/scan` | cookie + Origin | `{"path", "add"?, "depth"?, "git_only"?, "configured_only"?}`: the folders below a folder (default one level, `depth` is clamped to 1 to 6; a repository only at its root, linked worktrees skipped) that are git repositories (`git_only`, default `true`) and have a `devstack.toml` (`configured_only`, default `true`); both `false` is a 400 (ADR-0089). `[{repo, id, name, error, configured, registered, added}]`: `configured` false is a folder without a stack file, named after the folder; with `add` the valid new ones are registered |
Expand Down
Loading
Loading