Repository navigation
Conversation
Contributor
|
| Project | Bencher |
| Branch | u/ep/runner-protocol/health-email |
| 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.54%)Baseline: 5.14 µs | 6.07 µs (85.20%) |
| Adapter::Magic (JSON) | 📈 view plot 🚷 view threshold | 5.02 µs(+1.06%)Baseline: 4.96 µs | 5.73 µs (87.56%) |
| Adapter::Magic (Rust) | 📈 view plot 🚷 view threshold | 24.67 µs(-8.39%)Baseline: 26.92 µs | 30.76 µs (80.19%) |
| Adapter::Rust | 📈 view plot 🚷 view threshold | 4.49 µs(-0.31%)Baseline: 4.50 µs | 6.34 µs (70.78%) |
| Adapter::RustBench | 📈 view plot 🚷 view threshold | 4.47 µs(-0.49%)Baseline: 4.50 µs | 6.34 µs (70.57%) |
Each write that changes a runner's stored status can mail every server admin: when its disk health changes state, when it gains a finding while not ok, when a pause runs past 12 hours, and when such a pause ends. Nothing is mailed for health the server cannot read, for a first ok, or for a report that changes nothing. The API's write lock is held across the status read and write, so two channels for one runner mail once: the second reads the first's row and changes nothing. A pause crossing 12 hours is itself a change worth storing, and a pause keeps the start it was stored with, so a runner restart does not start it over.
epompeii
force-pushed
the
u/ep/runner-protocol/health-email
branch
from
October 8, 2026 17:21
82e6032 to
4e2b6fe
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 branch was previously deployed
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
Mail every server admin when a write that changes a runner's stored status is news.
ok, and when it gains a finding while notok, such as a second array degrading while the first already is. A new finding is a device and kind that the stored findings lack, so a finding that worsens in place mails only if it changes the host's state.sincemails at once.ok, for a pause that ends within 12 hours, or for a report that changes nothing.UPDATEandON CONFLICT DO NOTHINGin that write are a second guard, not a version check:changedis stored in whole seconds, so two writes in one second would both pass it.sinceit was stored with, so a runner that restarts mid-pause, for example to update itself, does not start it over.sinceis the runner's clock.A runner that sends no
healthand never pauses, as every runner does today, never mails.Why
A degraded array or a failing NVMe drive on a runner host is silent today: nothing reaches an admin until the next disk fails too. A runner that stays paused for half a day, behind a lock left held or a maintenance marker nobody removed, quietly takes no Jobs.
A first report that is not
okmails, because a runner whose first report is a degraded array is exactly the case to catch. A firstokis not news.12 hours outlasts one run of mdadm's scheduled check, which stops itself after 6 hours, so a routine scrub never mails.
Keying every mail to the write that changes the stored row means no reminders and no mail per report, with no state beyond the row.
Verification
health_changes_mail_each_admin_once, with two admins andok,warning,warningagain,failing, thenok: mailing on every report, on a firstok, or only one admin, and no mail on recovery.new_finding_while_failing_mails, withmd0failing, thenmd0andmd1, thenmd1alone, for two mails: mailing only on a change of state, mailing when a finding clears, and comparing findings without their identity.unknown_health_mails_nothing, with no health, a short pause, and an unknown state: mailing on health the server cannot read.long_pause_mails_once_and_its_end_mails_once, on a mock clock: a 1 hour pause ends with no mail, and a pause the runner restarts midway mails once past 12 hours, not again when its reasons change, and once when it ends. Kills no mail for a long pause, no write when a pause grows long, a mail on each reason change, no mail at its end, a mail at a short pause's end, and a runner restart starting the pause over.pause_seen_late_mails_at_once: timing the pause from when the server first saw it.html_escapes_runner_strings: dropping the escape.two_channels_mail_oncesends the same failing report from two channels for one runner at once and counts one mail per admin. It pins the scenario rather than a mutation: the write lock is what makes it hold, and removing either conditional write leaves it green.bencher_json,bencher_schema,bencher_otel,api_runners,bencher_runner, andbencher_api_testspass, and the status and mail tests pass 20 of 20 runs.cargo gen-specand typeshare show no change, and clippy passes with-D warningsfor Linux x86_64, Linux aarch64, and macOS.