Repository navigation
Keep each runner's latest status and show it to admins - #1125
Merged
epompeii merged 1 commit intoOct 8, 2026
Merged
Conversation
Contributor
|
| Project | Bencher |
| Branch | u/ep/runner-protocol/status-store |
| Testbed | intel-v1 |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result microseconds (µs) (Result Δ%) | Upper Boundary microseconds (µs) (Limit %) |
|---|---|---|---|
| Adapter::Json | 📈 view plot 🚷 view threshold | 5.17 µs(+0.45%)Baseline: 5.14 µs | 6.07 µs (85.12%) |
| Adapter::Magic (JSON) | 📈 view plot 🚷 view threshold | 5.02 µs(+1.10%)Baseline: 4.96 µs | 5.73 µs (87.60%) |
| Adapter::Magic (Rust) | 📈 view plot 🚷 view threshold | 24.03 µs(-10.76%)Baseline: 26.93 µs | 30.68 µs (78.34%) |
| Adapter::Rust | 📈 view plot 🚷 view threshold | 4.49 µs(-0.35%)Baseline: 4.50 µs | 6.34 µs (70.75%) |
| Adapter::RustBench | 📈 view plot 🚷 view threshold | 4.47 µs(-0.48%)Baseline: 4.50 µs | 6.34 µs (70.58%) |
epompeii
marked this pull request as ready for review
October 8, 2026 04:20
A runner's `ready` and `paused` can carry its host's disk health. The server keeps each runner's availability, pause reasons, pause start, and health in a new `runner_status` table, written only when the availability, the reason kinds, the health state, or the findings change. A report without health keeps the stored health, and lists and strings from the runner are capped before they are stored. `JsonRunner` gains `status`. A status row this build cannot read, such as one a newer server wrote, shows as no status with a warning, so the runner and the runner list still load, and the runner's next report replaces it. `QueryRunner::into_json` now takes the logger for that warning rather than gaining an `into_json_with_log` beside it: every caller needs a real logger, so the old function would be left with no caller. `runner.last_heartbeat`, which nothing wrote before, is now written from `ready`, `paused`, and job heartbeats, at most once every five minutes.
epompeii
marked this pull request as draft
October 8, 2026 17:21
epompeii
force-pushed
the
u/ep/runner-protocol/status-store
branch
from
October 8, 2026 17:21
cb96912 to
397a8df
Compare
epompeii
marked this pull request as ready for review
October 8, 2026 19:01
This was referenced Oct 9, 2026
epompeii
added a commit
that referenced
this pull request
Oct 10, 2026
## What Make `runner up` probe its host's md arrays before each `ready`, and send `paused` instead while any array syncs, so no Job starts on disks that a resync, recovery, or scrub keeps busy. This is the runner half of `paused` (#1122). - **The probe** runs only at the idle decision point: after any pending result is resent, before each `ready`, never during a Job. It reads `sync_action`, `sync_completed`, and `sync_speed` for each `/sys/block/md*` entry with an `md/` directory. - An array is busy while `sync_action` is `resync`, `recover`, `check`, `repair`, or `reshape` and `sync_completed` is not `none`, which covers a running sync (`N / M`) and one queued behind another array (`delayed`). - `idle`, `frozen`, an action this runner does not know, an array with no sync thread such as raid0, and a host with no arrays never pause. - **`paused`** carries one `raid` reason per busy array, with its action, progress, and speed, plus `since` and every `ready` field. `since` is when the pause began by the runner's clock, and it holds for the whole pause, whatever its reasons become. - **After `paused`** the runner waits for `no_job` or `update` exactly as after `ready`, then probes again. The server holds the poll, so a paused runner stays connected, still updates itself, and takes Jobs again within one poll of the sync ending. - **A Job sent to a paused runner** is failed unrun, with `The runner was paused for a RAID sync on md0, so it ran no Job`, through the usual terminal message, ACK, and retry, and no `running`. - **Reconnects while paused** first hold off one poll timeout, ahead of the usual 5 to 10 s delay, on every path that reconnects. The hold sleeps in slices of at most 1 s, so a stop ends it within a second. - **Logs:** one `Paused for a RAID sync` record per busy array when a pause begins (`array`, `action`, `percent`, `speed_kib`), `Pause ended` when it ends, and `Holding off the reconnect while paused` with `hold_secs`. A pause whose reasons change mid-pause is not logged again. - **`--no-raid-pause`** on `runner up` keeps taking Jobs through a sync. The pause is on by default, and `raid_pause` is in the `Runner starting` record. - The `runner up` reference documents the flag in all 9 languages, and the changelog gains a line. With #1125 and #1130 on the server, the pause shows on the admin runner endpoints, and a pause past 12 hours mails the server admins. Across versions: - A server with #1122 holds the paused poll and answers `no_job` on the same channel. - A server without it cannot parse `paused`, so it closes the channel. The runner then reconnects no faster than once per poll, so such a server sees no more connects than polls, and no self-update reaches the runner until its pause ends. The first `ready` after the pause takes Jobs as before. ## Why A sync reads or writes the whole array, and a Job measured during one measures the disks' contention as much as the benchmark. Probing only between Jobs leaves a running Job alone: a sync that starts mid-Job does not stop it, and the next Job waits. `sync_action` alone is not enough. It reads `recover` while a recovery is needed but cannot run, such as on a degraded array with no spare, which would pause the runner until someone adds a disk. A running or queued sync thread is what keeps the disks busy, so `sync_completed` has to say one exists. Holding the poll on the server, rather than sleeping on the runner, reuses the timers `ready` already has, so the runner needs no sleep of its own for the pause. The reconnect hold is for a server without `paused`. Without it, a runner whose channel closes on every `paused` reconnects every 5 to 10 s, about 480 times an hour, and trips a runner connect limit of 256 an hour after about half an hour; connects then fail even after the pause ends, until the hour drains. With the hold, a runner reconnects at most about `3600 / (poll + 7.5)` times an hour: about 58 at the default 55 s poll. A poll under about 7 s would still pass 256 an hour against such a server. The server never claims a Job for a paused runner, so a Job that arrives anyway is failed rather than measured on busy disks. ## Verification - Each new test fails under a mutation of the behavior it guards: - `a_running_sync_of_each_kind_pauses`: a busy set that misses an action, or counts `frozen`, `idle`, or an unknown action as busy. - `a_sync_action_with_no_sync_thread_does_not_pause`: busy on `sync_action` alone (`recover` with `sync_completed` `none`). - `a_queued_sync_pauses_with_no_progress`: `delayed` not busy. - `a_pause_reason_carries_the_progress_and_speed`: swapped or dropped progress and speed, and an array named after anything but its block device. - `a_host_with_no_arrays_never_pauses` and `an_array_with_no_sync_thread_is_listed_but_never_busy`: a disk with no `md/` read as an array, a host with no `block` directory failing, and raid0 dropped or busy. - `a_busy_probe_pauses_and_a_clear_one_sends_ready`: the probe's reasons ignored, a `paused` without `ready`'s fields (the server's update check needs the runner metadata), and a `no_job` that does not probe again. - `a_pause_keeps_its_start_and_is_logged_once_each_way`: a `since` that restarts each probe or outlives the pause, and a start or end logged every poll. - `a_paused_runner_still_updates` and `a_job_after_a_pause_fails_without_running`: a pause that ignores `update`, and a paused runner that runs a Job. - `reconnects_hold_off_a_poll_only_while_paused`, at a 55 s poll, drives every path that can reconnect while paused: the channel closed, a refused connect, a receive timeout, a failed self-update, a Job failed unrun whose result is lost with the connection, and each of the 3 ways its resend can fail at the next connect. Removing the hold at any one of those 8 sites fails it, and so do a fixed 30 s hold and a hold that outlives the pause. The ninth reconnect site, a connection lost during a Job, cannot be reached while paused. - `a_paused_reconnect_holds_off_for_the_whole_hold` and `a_stop_ends_a_hold_within_one_slice` run the hold through the driver's effect: a hold that does not sleep, and one a stop cannot end. - `no_raid_pause_takes_jobs_through_a_sync` and `the_raid_pause_is_on_unless_turned_off`: the flag ignored by the probe, inverted, or off by default. - None of the new tests compiles on the parent, which has no probe. The 14 runner tests and the CLI test pass 20 of 20 as an ordinary user and as root. - **In a disposable VM**, a root `runner up` at a 5 s poll ran against a local API, with a RAID1 over two 2 GiB loop devices: - `echo check > sync_action` paused the runner within 4 s, with `Paused for a RAID sync` (`md0`, `check`), and the server stored `paused` with the `raid` reason, its progress, and its speed. - A Job submitted then read `pending` at each of 12 checks over 60 s. - `echo idle` ended the pause at the next probe, 1 s later, and the Job was claimed that second and processed 2 s after. - The whole run used one channel. A second run at a 7 s poll behaved the same. - **Against a server built from the commit before #1122**, with its runner connect limiter on at 16 a minute and 256 an hour, a root `runner up` at a 20 s poll was held paused by a maintenance marker from the next layer in this stack; the hold does not depend on the reason. - Each `paused` closed the channel, and the runner logged `Holding off the reconnect while paused` with `hold_secs` 20. - Over 627 s it made 24 connects, 25.0 to 30.0 s apart: at most 3 in any minute, and 132 an hour. No connect drew a 429, while a burst of 20 connects with the same key at the end drew 5. - Once the marker was gone, the next connect probed clear and a waiting Job was claimed 9 s after the marker came off. - A hold that does not sleep reconnected every 5.0 to 10.0 s against the same server, 483 an hour. - SIGTERM 2.5 s into a 20 s hold ended `runner up` in 0.50 s. - The runner unit tests pass as an ordinary user and as root, 427 of 427, the CLI tests pass, 14 of 14, the `runner_ops` tests pass, 86 of 86, `cargo test-runner scenarios --build-only` passes, `Cargo.lock` is unchanged, and clippy passes with `-D warnings` for Linux x86_64, Linux aarch64, and macOS on the runner, its CLI, `test_runner`, and `runner_ops`. The scenario suite passes as root, 99 of 99, and clippy passes for the whole workspace as CI runs it, on the top of this stack.
epompeii
added a commit
that referenced
this pull request
Oct 10, 2026
## What Make the runner send its host's disk health with every `ready` and `paused`, in the `health` field that #1125 stores, so admins see it on the runner endpoints and #1130 mails them when it is news. - **md, at every probe:** each array's `array_state`, `degraded`, and `sync_action`, read with the RAID pause's own read. An array with no sync thread, such as raid0, reads `idle`. A degraded array is a `degraded` finding that is `failing`. - **NVMe, at most hourly:** each controller under `/sys/class/nvme`, with its model, its serial, and the SMART / health log fields that set a finding: critical warning, temperature, spare and its threshold, percentage used, and media errors. The page is read with Get Log Page (log `0x02`, all namespaces, 512 bytes) through the kernel's admin passthrough, `NVME_IOCTL_ADMIN_CMD`, on a read-only open of `/dev/<controller>`. The read is cached for an hour, and only the probe reads it, so never during a Job. - **States:** - `warning`: spare at or below twice its threshold, percentage used over 80, the temperature critical warning bit, or any media and data integrity error; - `failing`: any other critical warning bit, spare below its threshold, or a degraded array; - the host's state is its worst finding, and `ok` with none. - **A runner that is not root** cannot use the passthrough, which needs `CAP_SYS_ADMIN`. It lists each controller with no log, warns once with `NVMe health not read, so it is reported unreadable`, and still reports md. - Health is always sent: a host with no arrays and no controllers reports `ok` with empty lists. - **Nothing pauses on health.** A degraded array keeps taking Jobs; only a sync pauses, as before. - `AdminCommand` is the kernel's `struct nvme_admin_cmd`, pinned at 72 bytes by a const assertion. `nix` gains its `ioctl` feature, which adds no package to `Cargo.lock`. - The changelog gains a line. Across versions: - A server without #1125 ignores `health`, since the runner messages accept unknown fields. - `paused` needs a server with #1122, as in the layers below. ## Why A degraded array or a failing NVMe drive on a runner host is silent until the next disk fails too. The server half stores health and mails admins on news; this is what sends it. md costs a few sysfs reads, so it is read at every probe. Each NVMe read is an admin command to the drive, so it runs at most hourly, and only between Jobs. The temperature bit is a warning, not failing, because it clears by itself. Media errors warn while their count is nonzero, rather than when it rises, which would read `ok` again at the next hourly read. Health is reported, never a pause. An idle degraded array barely moves a benchmark, and the mail reaches whoever can replace the disk. Health still rides on `paused`, because the rebuild after a disk is replaced is a pause, and that is when health matters most. ## Verification - Each new test fails under a mutation of the rule it guards: - The NVMe parser runs on fixture pages. `a_page_parses_little_endian_at_its_offsets` and `a_media_error_count_past_u64_saturates`: swapped temperature bytes, media errors read big-endian or from the wrong counter, spare read from the threshold byte, and a 128-bit count that wraps. - `a_healthy_page_has_no_findings` and `each_critical_warning_bit_but_temperature_is_failing`, over bits 0 and 2 to 7: a rule that fires on a healthy page, any one critical bit missed, and the temperature bit failing or ignored. - `spare_at_twice_its_threshold_warns_and_below_it_fails`, `percentage_used_over_80_warns`, and `any_media_error_warns`: either spare boundary or the endurance boundary moved by one, and media errors ignored or failing. - `an_unreadable_log_still_lists_the_controller`: an unreadable controller dropped, and a log read from another device. - `a_degraded_array_is_failing` and `the_worst_finding_sets_the_state`: a degraded array that reads healthy, every array failing, and the state taken from the first finding rather than the worst. - `nvme_is_read_at_most_hourly`, on an injected clock and reader: read once at the start, served from the cache 1 s before the hour, and read again at the hour. Kills a read every probe, and one never repeated. - `an_unreadable_nvme_still_reports_md` and `every_probe_reports_md_health`: a runner that is not root reporting nothing, and a probe that sends no health, or none with the RAID pause off. - `the_probes_health_rides_on_ready_and_paused`: health dropped from either message. - None of the new tests compiles on the parent, which reads no health. The 14 tests pass 20 of 20 as an ordinary user and as root. - A C probe against Ubuntu 24.04's `linux/nvme_ioctl.h` gives `sizeof(struct nvme_admin_cmd)` 72, `NVME_IOCTL_ADMIN_CMD` `0xc0484e41`, and `addr`, `data_len`, and `cdw10` at offsets 24, 36, and 40, which the Rust struct and `ioctl_readwrite!(b'N', 0x41)` match. - **In a disposable VM**, an NVMe controller on the kernel's `nvme-loop` target, backed by a file, stood in for a drive: - As root, the runner's own read returned the page with status 0, and the page's data units read and host read commands equal `nvme smart-log`'s values for that controller. - As an ordinary user, the read fails with `EACCES`, the controller is listed with no log, and md is still reported. - A dword count off by one fails there with status `0x600f`, which the fixture pages cannot show. - **In the same kind of VM**, a root `runner up` ran against a local API, with a RAID1 over two loop devices: - Healthy, the server stored health `ok` with `md0` `clean`, 0 degraded, `idle`. - `mdadm --fail` on one member: the next report read `failing`, with `md0` `degraded` `failing`, and the runner still `ready`. A Job submitted then ran. - `mdadm --remove` and `--add`: the runner paused for the `recover` sync with health still `failing`. Once the recovery finished, the pause ended, and the next report read `ready` and `ok`. - The runner unit tests pass as an ordinary user and as root, 455 of 455, the CLI tests pass, 14 of 14, the `runner_ops` tests pass, 86 of 86, `cargo test-runner scenarios --build-only` passes, `Cargo.lock` is unchanged, and clippy passes with `-D warnings` for Linux x86_64, Linux aarch64, and macOS on the runner, its CLI, `test_runner`, and `runner_ops`. The scenario suite passes as root, 100 of 100, and clippy passes for the whole workspace as CI runs it, on the top of this stack.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Store each runner's latest availability, pause reasons, and disk health, and return them on the admin runner endpoints.
readyandpausedcan carry the host's diskhealth.JsonReady::new_with_healthsits besideJsonReady::new, whose signature is unchanged.state: the worst of the findings,ok,warning, orfailing.findings: each a device, a kind such asdegradedormedia_errors, and a state.arraysandnvme: every md array, and every NVMe controller with its model, serial, and SMART / health log fields.runner_statustable keeps one row per runner: availability, pause reasons,since, health, andchanged. The server writes it only when the availability, the set of reason kinds, the health state, or the findings change, so RAID progress or a new temperature reading writes nothing, andchangedis when the current status took effect.healthkeeps the stored health.JsonRunnergainsstatus, so the admin runner endpoints, the spec add response, andbencher system runner viewshow it. It stays admin-only, since it carries disk models and serial numbers.QueryRunner::into_jsontakes the logger for that warning rather than gaining aninto_json_with_logbeside it: every caller needs a real logger, so the old function would be left with no caller.runner.last_heartbeat, which nothing wrote before, is now written fromready,paused, and job heartbeats, at most once every five minutes per runner, by one conditionalUPDATE. It is the "as of" for a stored status.HealthState,HealthFindingKind, andMdSyncActioneach end in a catch-all for values this server does not know, and each gets a plain string schema inopenapi.json. schemars would describe the catch-all as an object, which misstates the wire and would break the generated client on an unknown value.reasonsandhealthloose types, since typeshare cannot express internally tagged enums, untagged variants, oru64. No console page reads them.healthonreadyin all 9 languages, and the changelog gains a line.Across versions:
readystores its availability and liveness and leaves any stored health alone.health.Why
The server kept nothing about a runner between Jobs. An admin could not see whether a runner was taking Jobs, why it was paused, or whether its disks were healthy, and
last_heartbeatwas onJsonRunnerbut never written, so it was always empty.Health rides on
readyandpausedrather than a separate route, so a paused runner still reports it. The rebuild after a disk replacement is a pause, and that is when health matters most.Writing only on change keeps each
readyorpausedto a primary key read and a conditionalUPDATEunder the write lock, which the idle claim loop already takes every second. A table of its own keeps therunnerrow lean and needs no rebuild of a table thatjobandrunner_specreference.Verification
ready_stores_healthandpause_is_stored_and_ready_clears_it: no write fromreadyor frompaused.unchanged_report_keeps_changedandpause_progress_keeps_changed, on a mock clock: an identical report, one that differs only in array detail, and a pause whose progress moves all keepchanged, and a new finding or a new reason kind moves it. Kills writing on every message, and comparing whole health or whole reasons.ready_without_health_keeps_stored_health: an absenthealthoverwriting the stored one.oversized_report_is_capped: 20 reasons and 100 findings are answeredno_joband stored as 16 and 64. Kills storing either uncapped.cap_bounds_lists_and_strings: truncating without the character boundary, which panics on a 3 byte character at the cut.non_admin_cannot_read_runner_status: dropping the admin gate onGET /v0/runners/{runner}, which no test covered before.last_heartbeat_is_written_at_most_every_five_minutes, written at t0, not at t0 + 299 s, and again at t0 + 300 s, andjob_heartbeat_writes_last_heartbeat: writing it on every message, or never fromready,paused, or a job heartbeat.unreadable_status_reads_as_noneandunreadable_status_is_replaced_by_the_next_report: reading an unreadable row as a missing runner, a missing or doubled warning, and keeping the unreadable row.unknown_health_state_is_other: dropping the catch-all.reordered_findings_keep_changed: the same findings reordered or repeated leavechangedalone. Kills dropping the sort or the dedup.stored_pause_reason_strings_are_capped: a 128 byte array name is stored, and read back, as 64 bytes. Kills storing pause reason strings uncapped.migration_down_and_up_drops_and_restores_the_table: a down migration that keeps the table. It reverts in a loop down to this migration, so a later migration does not break it.JsonRunnerandJsonRunnerStatusround-trip every status shape without loss: no status, ready, paused with each reason kind, an unknown sync action, health state, and finding kind,u64::MAXcounters, and an absent NVMe log;healthset tonot jsonorreasonsset to{read as no status with one warning per read, the runner list still loads, and the nextpausedreplaces them.bencher_json,bencher_schema,bencher_otel,api_runners, andbencher_runnerpass, and the status tests pass 20 of 20 runs.cargo gen-specand typeshare reproduce the committed files, and clippy passes with-D warningsfor Linux x86_64, Linux aarch64, and macOS.