Skip to content

drums preflight: check a run can start before any GPU is paid for - #13

Merged
sahiljagtap08 merged 4 commits into
mainfrom
fix/w4-preflight
Nov 18, 2026
Merged

sahiljagtap08 merged 4 commits into
mainfrom
fix/w4-preflight

Conversation

@sahiljagtap08

Copy link
Copy Markdown
Contributor

What changed (learnings doc "Preflight"; D1 blocks A-04, A-27, A-29, A-30 seen from the client)

drums preflight --desktops N --hours H [--model-gpus 2:6] [--task-set ID|name] [--json] [--strict] on the CLI, and drums.preflight(desktops, hours, ...) returning a PreflightReport (.ok, .checks, .table(), .to_dict(), .exit_code(strict)). It only reads; it creates nothing.

Check Source on today's gateway
gateway (control-plane health and latency: over 2 s warns, over 20 s fails) GET /v1/health
console answers GET <console>/sign-in, no token sent
auth: accepted, not revoked, does not expire before the run ends; another workspace's gateway (403 host binding) is named /v1/health plus GET /v1/api-keys, matched by key prefix
scopes: computers:read and computers:write required; runs:write and usage:read warned same row
host capacity: at least N free on the bound host /v1/health capacity
admission: drumsd ok, no stale checkpoint, host not draining /v1/health, plus host.status from /v1/limits when present
rate limit vs N x REQUESTS_PER_DESKTOP_S (0.5, the D1 rule, explicit and documented), burst vs N x BURST_PER_DESKTOP (1.0) GET /v1/limits (not served yet)
quota: live-desktop limit minus live >= N GET /v1/limits (not served yet)
spend cap: spent + N x H x desktop-hour price <= cap GET /v1/limits (not served yet); --desktop-hour-usd supplies the price
task set: registered, and validated (accepted > 0, rejected 0, on the bound host when known); a platform set with no record is a warning GET /v1/task-sets/{id}, or a name looked up in the list
model GPUs: informational, with --gpu-hour-usd for a GPU cost projection arguments

Every row that is not a pass carries a fix and a console link (/w/<slug>/usage, /api-keys, /computers, /tasks/<id>). The workspace slug comes from --workspace or DRUMS_WORKSPACE. Exit status: 1 when a check failed, 2 on a usage error, 0 otherwise. --strict also exits 1 on a warning or a row that could not be checked. The token never appears in any output.

Graceful fallback. Rate limit, quota, spend cap and price need a read-only GET /v1/limits summary that no gateway serves yet. Until one does, those rows say "not checked (this gateway does not publish GET /v1/limits yet)" and never fail the run. The one exception: the rate limit row warns when N needs more than the gateway's 20/s, burst 60 default. The shape preflight reads is in _limits_view:

{"workspace": {"max_live_computers", "live_computers", "max_spend_usd", "spent_usd", "period_end"},
 "rate_limit": {"per_s", "burst"}, "price": {"desktop_hour_usd"}, "host": {"id", "status", "max_desktops", "live"}}

I propose that W1 or W3 serve this (with scope usage:read) together with the per-workspace rate profile and the desktop-hour price.

Live run (read-only, against https://beta.drums.run/gw with the D1 key, merged locally with #11 for the certificate fix)

drums: the system certificate store could not verify https://beta.drums.run:443; using certifi's CA bundle (to fix Python's own store on macOS, run "Install Certificates.command")
drums preflight: 128 desktops for 3 h

CHECK          RESULT       DETAIL
gateway        PASS         https://beta.drums.run/gw answered in 0.58 s (drumsd 0.4.2)
console        PASS         https://console.drums.run: HTTP 200 in 0.3 s
auth           PASS         key d1 accepted, no expiry
scopes         PASS         audit:read, computers:read, computers:write, runs:read, runs:write, templates:read, templates:write, usage:read
host capacity  FAIL         10 of 10 desktops free on the bound host; 128 needed
admission      PASS         drumsd ok, no stale checkpoint
rate limit     WARN         not checked (this gateway does not publish GET /v1/limits yet); 128 desktops need about 64 req/s, burst 128. The gateway's default is 20 req/s, burst 60
quota          NOT CHECKED  not checked (this gateway does not publish GET /v1/limits yet)
spend cap      NOT CHECKED  not checked: no desktop-hour price (this gateway does not publish GET /v1/limits yet); 384 desktop-hours

To do:
  [fail] host capacity: close idle desktops, or ask for a bigger host (or run 10 desktops) https://console.drums.run (Computers)
  [warn] rate limit: confirm the per-key limit of your host with support before a large run
  [not checked] quota: see the workspace's live-desktop limit https://console.drums.run (Usage)
  [not checked] spend cap: pass --desktop-hour-usd to project the cost https://console.drums.run (Usage)

FAIL (1 check failed); 2 could not be checked

The first line is #11's certifi fallback in action. This macOS python.org Python has no root store, and without #11 the gateway row fails with CERTIFICATE_VERIFY_FAILED, which is A-07 exactly. The console row has its own certifi retry, so it does not depend on #11.

Tests

  • New tests/test_preflight.py (17 tests, localhost fake gateway). It covers: today's gateway (passes what it can; rows it cannot check say so and pass non-strict); the explicit rate rule (128 desktops need 64 req/s, a warning against the 20/s default); with /v1/limits every row is decided; each limit fails with its fix and link; the price flag; host capacity and admission (full, drumsd not ok, stale checkpoint, draining); key expiring during the run, missing or wanted scopes; wrong key and another workspace; unreachable gateway; slow control plane; task set (missing, never validated, platform, rejected, by name, validated on another host); the console row; model GPUs; bad arguments; and the CLI table, exit codes, --json, usage errors, and no token in output.
  • The full suite passes locally; CI runs 3.9 to 3.13.

@sahiljagtap08
sahiljagtap08 merged commit 09964c6 into main Nov 18, 2026
5 checks passed
@sahiljagtap08
sahiljagtap08 deleted the fix/w4-preflight branch November 18, 2026 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant