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

### Fixed

- **A lane on a node keeps its journal** (#287): the requester's take of
the lane daemon's telemetry lines, every 30 seconds, went into that
daemon's journal as "take the telemetry lines by an unknown client" and
pushed the lane's real changes out within about four hours; its log
line was also the next take's telemetry. The take is no longer
journaled or logged as a request.
- **`devstack up` waits for the containers too** (#66): it waited for the
autostart services only, so a stack of Compose groups alone answered
right away while its images were still built and its containers started.
Expand Down
25 changes: 21 additions & 4 deletions crates/devstack-daemon/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,7 @@ pub fn router(state: AppState) -> axum::Router {
/// by the main API it came through (with the lane), not again by the lane's.
async fn audit(State(s): State<AppState>, req: Request, next: Next) -> Response {
let method = req.method().clone();
if method == axum::http::Method::GET
|| method == axum::http::Method::HEAD
|| !s.sup.lane.is_empty()
{
if !s.sup.lane.is_empty() || !audited(&method, req.uri().path()) {
return next.run(req).await;
}
let path = req.uri().path().to_string();
Expand Down Expand Up @@ -150,6 +147,17 @@ async fn audit(State(s): State<AppState>, req: Request, next: Next) -> Response
res
}

/// Whether a request changes something a person may ask about afterwards.
/// Not a read, and not the requester's take of a lane daemon's telemetry
/// lines (#287): it comes every 30 seconds and would push the lane's real
/// changes out of the journal within hours, and its own log line would be
/// the next take's telemetry.
fn audited(method: &axum::http::Method, path: &str) -> bool {
method != axum::http::Method::GET
&& method != axum::http::Method::HEAD
&& path != "/v1/telemetry/take"
}

#[derive(Deserialize)]
struct JournalQuery {
/// Unix ms: only what came after.
Expand Down Expand Up @@ -1950,6 +1958,15 @@ mod tests {

const GB: u64 = 1 << 30;

#[test]
fn the_telemetry_take_is_no_change_to_audit() {
use axum::http::Method;
assert!(!audited(&Method::POST, "/v1/telemetry/take"));
assert!(!audited(&Method::GET, "/v1/services/api/restart"));
assert!(audited(&Method::POST, "/v1/services/api/restart"));
assert!(audited(&Method::DELETE, "/v1/store/api/abc"));
}

#[test]
fn containers_in_docker_desktops_vm_are_checked_against_the_vm() {
// The case of #309: the host has plenty, the VM does not.
Expand Down
2 changes: 1 addition & 1 deletion docs/dashboard-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ type StoreView = {

| Method and path | Answer |
|---|---|
| `GET /v1/journal?since=` | what changed the stack at runtime ([ADR-0067](adr/0067-a-change-at-runtime-says-who-made-it.md)), oldest first, the last 500, kept across restarts in `.devstack/journal.ndjson`: `[{at, via, lane?, method, path, status, error?}]`. Every request but `GET`/`HEAD` that came through the main tree's API (a lane's under `/v1/lanes/<lane>/...`, with `lane`), refused ones with their `status` and `error`; devstack's own change of the main slot as `method: "AUTO"`, `via: "auto"`, with the path the API would have taken. `since`: Unix ms. A lane's API answers the same, the stack's journal. `via` is the client the request named in `X-Devstack-Client` (`cli`, `mcp`, `dashboard`, `tray`), else `unknown`; the hub sets `dashboard` for a request with its session cookie and drops what a browser sent |
| `GET /v1/journal?since=` | what changed the stack at runtime ([ADR-0067](adr/0067-a-change-at-runtime-says-who-made-it.md)), oldest first, the last 500, kept across restarts in `.devstack/journal.ndjson`: `[{at, via, lane?, method, path, status, error?}]`. Every request but `GET`/`HEAD` (and `POST /v1/telemetry/take`, a requester's take every 30 seconds) that came through the main tree's API (a lane's under `/v1/lanes/<lane>/...`, with `lane`), refused ones with their `status` and `error`; devstack's own change of the main slot as `method: "AUTO"`, `via: "auto"`, with the path the API would have taken. `since`: Unix ms. A lane's API answers the same, the stack's journal. `via` is the client the request named in `X-Devstack-Client` (`cli`, `mcp`, `dashboard`, `tray`), else `unknown`; the hub sets `dashboard` for a request with its session cookie and drops what a browser sent |
| `POST /v1/up` | `202` |
| `POST /v1/down?infra=true&all=false` | `204` when every service stopped and, with `infra=true` (the default since 0.25.0, [ADR-0068](adr/0068-a-stop-takes-the-containers-too.md)), the containers were removed, volumes kept; `infra=false` leaves them running. `409 {"error"}` naming what did not stop. In the main tree while lanes run: `200 {"lanes": [...], "kept": [...], "containers": [...]}`; `kept`: the services that serve the lanes and keep running (`lanes = false`, and what they start `after`); `containers` (`<group>.<service>`, or a whole `<group>` that lists no `services`): what `infra` left running, the containers a kept service comes `after` and, while a lane runs on this machine, the `shared` ones (ADR-0030); every other container of the main tree goes. With `all=true` the lanes stop first, each with its own containers (a lane on the main ports gives them back first, a lane on a node is released), so `infra` then removes the main tree's containers too |
| `POST /v1/shutdown?unless_lanes=false&restart=false` | `202`; the daemon stops its lanes and services and exits (`devstack down`). With `unless_lanes=true` and a lane running: `409 {"error", "lanes"}`, and it stays. With `restart=true` it exits whatever runs and leaves its lanes to the next daemon ([ADR-0052](adr/0052-a-restart-carries-the-lanes-over.md)): it writes `.devstack/restart.json` (the lanes here with their profile, those on nodes with their lease and ports, who serves the main ports) and keeps the leases of its lanes on nodes; a daemon started within two minutes renews them and follows those lanes again, starts the lanes here again from the artifacts they ran, and gives the main slot back to its lane once the main tree's `up` is done |
Expand Down
Loading