Skip to content

PLX-253: every runner host mails its tenant of a full disk, a failed unit and a slot that cannot register - #92

Merged
davidjalbers merged 15 commits into
plain-pipeline-2from
davidjalbers/plx-253-every-runner-host-notifies
Dec 3, 2026
Merged

davidjalbers merged 15 commits into
plain-pipeline-2from
davidjalbers/plx-253-every-runner-host-notifies

Conversation

@davidjalbers

@davidjalbers davidjalbers commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

PLX-253: every runner host set up by plexus.ci.playbook mails its tenant when its disk passes the threshold, when a unit of its own fails, and when a slot cannot register for longer than a few minutes.
Since 0.135.0 a runner host sent no mail.

Mechanism

  • The playbook mounts the host baseline's mail role, as the platform's playbook does: Postfix send-only, every sender and recipient rewritten to the tenant's, and the role's failure-mail@ as the OnFailure= of every service, at most once a day per unit (mail_failure_interval).
  • mail_smtp comes from the vault <owner>-ci-host, one item read like the others in vars/vault.yml, its entries marked optional.
  • A failed unit: BuildKit, the cache servers, the housekeeping and a slot's container mail at once, as any unit on an app host.
  • A disk over the threshold: ci-runner-disk.service, hourly by its own timer, a unit apart from the housekeeping, fails when the root file system is fuller than actions_runners_disk_alert_percent (85).
    Its mail says "root file system N% used" and "above 85%: look at …".
    Being a unit of its own, it has its own daily budget: a pull that failed earlier the same day takes nothing from it, and a pull that fails because the disk is full does not keep it from running.
  • A slot that cannot mint: a slot fails as a unit at every failed attempt (systemd 257 passes Restart=always through the failed state, so OnFailure= fires each time; tried).
    • The row: ci-runner-jit writes /run/ci-runner/<slot>.failing, the host's uptime in seconds (/proc/uptime, which no time step moves), as an attempt starts where there is no row, and removes it once it has minted.
      A start that is not one of systemd's restarts (NRestarts 0) begins a new row, since a stop between two attempts runs no ExecStopPost (tried) and would leave the old one.
      A minting that systemd ends for its time keeps the row, since it was written at the start.
    • The alert: after every attempt that failed, the slot's ExecStopPost starts ci-runner-cannot-register@<slot>.service (--no-block).
      It fails once the row is older than actions_runners_slot_alert_after (300 s) and says "the slot repo-1 has failed to mint its runner config at every attempt for 6 min 2 s", followed by the slot's last 20 journal lines; younger, or without a row, it exits 0 and nobody is mailed.
      Being a unit of its own, it has its own daily budget: a container of the slot that failed earlier the same day, which a job can cause on purpose, takes nothing from it.
    • The slot's own mail: a drop-in of failure-mail@.service (20-ci-runner.conf) adds ExecCondition=ci-runner-mail-hold %i, which holds back the mail on a slot while its row holds a number, that is, for a failed minting; a container that failed after it minted is mailed at once.
      A condition that holds back is no failure, and the role's script touches its stamp only after the condition, so a held-back attempt does not count as sent.
    • Towards mailing: a row that holds no number, a row ahead of the uptime, or a threshold that is no number makes ci-runner-cannot-register fail at once and say what it holds, and lets the slot's own mail go.
      A held-back minting is mailed only if the slot's ExecStopPost can start ci-runner-cannot-register@, as the hold's header says.
    • The retry loop, its 30 s wait and its cadence are unchanged.
  • An item that is missing, lacks a field, leaves one empty, or names a port that is not digits or a mode other than starttls or tls: no run fails; the host is set up and says in its journal (logger --tag plexus-ci --priority user.warning) "This host sends no mail: the item mail-relay of the vault <owner>-ci-host lacks port; the item mail-relay names the mode pigeon, which is neither starttls nor tls. …".
    What is wrong is computed from the variables, not from the reads, so a ci_mail_* given on the command line counts, as the header of vars/vault.yml says of every variable.
  • A mail role that fails (a Postfix that cannot be installed): the role runs in a block of the playbook's pre-tasks with a rescue, so no run fails, the slots start, and the journal says "This host sends no mail: the role plexus.host.mail failed at 'Install Postfix and mail(1)': …".
    It runs before the roles, as before ahead of the units it reports on, so that a slot that cannot register on the first run is mailed about.
  • A relay that refuses: no run fails, since the playbook does not speak to the relay; Postfix says it in the journal at each try (postfix/smtp: "SASL authentication failed; server … said: 535 …").

The vault item

mail-relay in <owner>-ci-host, fields in the style of the others, each filling the key of mail_smtp beside it:

Field mail_smtp What
server server the relay's name or address
port port e.g. 587
mode mode starttls or tls (implicit TLS)
username username the relay's user
password password its password
from-address from_address the sender of every mail, one the relay accepts
mailto mailto the tenant's mailbox

All seven, none empty, or none: anything less is a host without mail, and the journal line names what is wrong.
vars/vault.yml is the one place the fields are named; the headers of the Terraform module and of the rendered ci/main.tf name the item and point there.

A change to the mail role

The role assumes that nothing untrusted reaches the host's loopback: Postfix listens on 127.0.0.1:25 and, by its defaults (mynetworks_style = host, permit_mynetworks in smtpd_relay_restrictions, read in postconf(5), not tried), relays what loopback hands it.
A runner host's slots share its network, so a job could mail as the host, to the tenant's mailbox, through the tenant's relay.
The role gains mail_loopback_smtp, true by default; the runner host's playbook sets it false.
False comments out smtp inet in master.cf behind a mark of the role's (#closed by mail_loopback_smtp: ); true restores that marked line alone, so it round-trips and leaves a line commented out by hand as it is.
On an app host the file is unchanged: the task that reopens finds no marked line, and the one that closes is skipped (by reading; no app host was run).
mail(1), cron and failure-mail submit through sendmail(1) and are unaffected (the tests' mails go that way).

Tests

newborns/runner-host-mail.test.ts, a newborn beside runner-host.test.ts: the same privileged Debian 13 container with systemd, the same stand-in for op, a forge stand-in that refuses mintings or keeps one waiting when told, a relay stand-in on the host's loopback (STARTTLS, AUTH PLAIN and LOGIN, 535 when told, each message recorded), and in place of a slot's container a runner that waits for a job that never comes.
Thirteen tests, in order:

  1. A host without the item is set up, its slot and BuildKit run, and its journal says it sends no mail, naming the vault and the item.
  2. An item that lacks mailto, leaves username empty and names the port twenty-five and the mode pigeon, with ci_mail_mailto on the command line: the run passes, the slot runs, Postfix is not installed, and the journal names username, twenty-five and pigeon and not mailto.
  3. A mail role that fails (Postfix pinned away with an apt preference): the run passes, the slot runs, and the journal says the host sends no mail and names plexus.host.mail.
  4. With the item, a run at -vvv prints neither the relay's user nor its password, Postfix runs, and nothing listens on port 25.
  5. BuildKit and a cache server, killed, are one mail each, authenticated with the item's credentials, from its sender to its recipient, the subject naming the host.
  6. The housekeeping fails on a pull and mails; then a disk over the threshold is one more mail, about ci-runner-disk.service, that says how full, though the check fails twice.
  7. A slot's container that dies mails at once.
  8. With that mail sent the same day: one failed minting attempt mails nobody; a minting refused for longer than the threshold (60 s in the test) mails once, about ci-runner-cannot-register@repo-1.service, not before the threshold, saying "for 1 min …"; two more refused attempts mail nothing more, and the slot's own mails stay at the container's one.
  9. ci-runner-cannot-register and ci-runner-mail-hold by hand: no row (exit 0, mail); a young row (no mail, hold); a row 150 s old (mail, "for 2 min … s"); a row of garbage (mail at once, saying garbage; the hold lets the slot's mail go); a threshold soon (mail, saying soon).
  10. A slot stopped between two failed attempts (a wait of 40 s by a drop-in) keeps its row, and its next start begins a new one.
  11. A minting that hangs until systemd ends it (a start limit of 20 s by a drop-in) leaves a row.
  12. A relay that refuses is said by Postfix in the journal, nothing reaches it, and a further run passes.
  13. mail_loopback_smtp true by -e opens port 25 again, a run without it closes it, and a run after that reports the close task ok, not changed.

Red first, each run of the one file alone:

  • 7f72774, the first seven tests alone: all red, each because the host had no mail.
  • b8a4c31, the mail mounted without the hold: the slot's test red for the right reason, a single failed minting attempt mailed.
  • 036b65a, the review's points: tests 1 to 7 green as before; and on 7b016c2 (the new tests, with the code of 036b65a) eight red, each for its point: 2, the journal named mailto (from the read, not the variable) and not port (an empty field counted as present); 3, the run failed at "Install Postfix and mail(1)"; 6, no mail about ci-runner-disk.service (the check was the housekeeping's, whose day's mail the pull had taken); 8, no mail about ci-runner-cannot-register@repo-1.service within 5 min (the container's mail had taken the slot's day); 9, ci-runner-cannot-register not found; 10, the row after the new start was the old one; 13, port 25 stayed closed with mail_loopback_smtp true.
    Test 11 failed there on its own precondition, a row left by test 10's failure; be3d060 makes it wait for a running slot, and run alone after test 1 on the same old code it was red for its point: systemd ended the minting at 20 s and no row was left.
  • f82a5df, the code: all thirteen green, exit 0 in 775 s; and again on the merge 2b9a7c2 of plain-pipeline-2, exit 0 in 795 s.

mise run test: exit 0 on the merge 2b9a7c2 (check first), and on e4b94f3 after the merge of c64f5fe.
The port case (d77c621, e4b94f3) was added after the last newborn run and has not run in it; the coordinator's run covers it.

Tried, and not

  • Tried in the container: everything above.
    The disk was not filled: the container's root is the test machine's disk, so a drop-in puts the threshold under what the disk holds.
  • Not tried: a virtual machine set up from user-data alone (the issue's "Done when"), a real relay, a real provider.
    The container runs the same playbook against localhost as root with the bootstrap token alone; cloud-init and a disk of its own are what it lacks.
  • Not tried: a mail role that fails in its handlers (a Postfix that will not restart) rather than in a task; the role flushes its handlers inside the rescued block, and whether the rescue catches a failed handler there I have not seen.
  • Not run here: runner-host.test.ts, runner-unregister.test.ts and the rest of mise run e2e, left to the coordinator.
    They run the changed playbook (optional vault entries; the mail role skipped without the item) and the changed slot unit (one ExecStopPost that starts ci-runner-cannot-register@), and runner-host.test.ts asserts the housekeeping timer, which is unchanged beside the new disk timer.

Readings

  1. A slot's container that fails mails at once, like any unit, and only a failed minting waits: "a unit of its own fails (a slot …)" is the rule, "a slot that cannot register" the exception with its threshold.
  2. The two alerts the issue names beside a failed unit, the disk and a slot that cannot register, are units of their own (ci-runner-disk, ci-runner-cannot-register@<slot>), each with the mail role's daily budget per unit, rather than budgets of their own inside the mail role, which would be a second mailer or a larger role change.
    What still shares a budget: two failures of one unit on one day (the housekeeping's registry refresh and its pull; a slot's container twice; a slot that cannot register, recovers and cannot again) are one mail.
  3. A failed minting is held back by an ExecCondition on the mail role's unit, not by RestartMode=direct on the slot: with direct a failed attempt never fails the unit, but systemctl start then waits until a minting succeeds (tried: it hung), so the playbook's restart of the slots would hang through a forge outage.
  4. Once a day per unit is the "sane interval": the mail role's own mail_failure_interval.
  5. The threshold is 300 s ("a few minutes"), from the start of the row's first attempt; a failed attempt takes about 50 s, so the mail comes at the end of the sixth or seventh in a row.
  6. The whole item or none, rather than defaults for port and mode; an empty field counts as missing.
  7. The note on a host without mail goes to the journal by logger at each run, beside the run's output, which under cloud-init is a file nobody reads.
  8. Closing Postfix's port on loopback (above) is a change the issue does not name.
  9. The mail role runs first in the second play, before the baseline, rather than after it as an app host's playbook has it, so that its rescue can sit in the pre-tasks; it needs nothing of the baseline but the apt cache, which the first play updates.
  10. The playbook still fails where it failed before: a forge that refuses at the first run fails the handler that restarts the slots; the mail is set up by then, so the slot mails once the threshold is past.
  11. The mail of ci-runner-cannot-register and of a slot carries the slot's last journal lines, the runner's own output among them (job and repository names); it goes to the tenant's own mailbox.

For a tenant

Create the item mail-relay in <owner>-ci-host with the seven fields.
Hosts that exist get this with their replacement: a runner host is never updated.

Owed

  • The Decisions document: § 7.10 gains the item mail-relay, as the issue names; the maintainer's to write.
  • The compendium, approaches/delivery.md:
    • the runner-host paragraph ("holds its slots, the BuildKit service, its two cache servers and the environment image, and runs nothing else"): it also runs Postfix, send-only, and the page says nowhere yet that a runner host mails its tenant about a failed unit, a full disk and a slot that cannot register;
    • "What a runner host reads when it is set up" (§ 8): the list of <owner>-ci-host gains the mail relay, optional;
    • "What a tenant sets up", under byom: the vault's items gain the optional mail-relay, with the fact that the tenant provides the relay and that a host without it sends no mail.
      The field list stays in vars/vault.yml alone (§ 1.8, one home).
  • The compendium, approaches/platform.md: the CI playbook's roles ("takes the baseline, the container engine, plexus.ci.turbo_cache and plexus.ci.actions_runners") gain mail, and the line "On a CI runner host the role's removal is off" gains a twin for the mail role: on a CI runner host its SMTP port on loopback is closed (mail_loopback_smtp), since the slots share the host's network.
  • Not built, as the issue leaves it open: whether a host that is destroyed says so.

Done when, not met

No virtual machine: see "Tried, and not".

🤖 Generated with Claude Code

davidjalbers and others added 15 commits December 3, 2026 02:40
… item mail-relay (PLX-253)

A newborn of its own, beside runner-host.test.ts, with a stand-in relay on
the host's loopback that takes STARTTLS and AUTH and records what it is
handed, and a forge that refuses mintings when told: a host without the item
is set up and says so in its journal; with it, one mail per failed unit and
for a disk over the housekeeping's threshold, none for one failed minting,
one saying for how long for a slot that cannot mint past the threshold, no
SMTP port on the loopback the slots share, and a refusing relay said in the
journal.

Co-Authored-By: Claude Opus <noreply@anthropic.com>
…ult's item mail-relay (PLX-253)

The playbook mounts the host baseline's mail role as the platform's does,
with mail_smtp from the vault's optional item mail-relay (server, port,
mode, username, password, from-address, mailto). A vault without the whole
item fails no run: the host is set up, sends no mail, and says so in its
journal (logger, tag plexus-ci).

The mail role gains mail_loopback_smtp, true by default, so app hosts stay
as they are: false comments out master.cf's `smtp inet`, since a runner
host's slots share its loopback and would otherwise mail as the host.

Co-Authored-By: Claude Opus <noreply@anthropic.com>
… minutes, and says for how long (PLX-253)

A slot fails as a unit at every failed attempt and is started again, so the
host's mail on a failed unit would mail one refusal of the forge. ci-runner-jit
keeps the first failed attempt of a row in /run/ci-runner/<slot>.failing,
which a minting that succeeds, or a stop, removes, and says at each failure
for how long the slot has failed. A drop-in of failure-mail@ adds an
ExecCondition, ci-runner-mail-hold, which holds back the mail on a slot until
that row is actions_runners_slot_alert_after old (300 s); a slot whose
container failed, and every other unit, mails at once. The retry loop and its
cadence are unchanged; the mail role's daily interval keeps it to one mail.

The headers of the playbook, of both Terraform modules and of the template's
root ci/ name the vault's item mail-relay.

Co-Authored-By: Claude Opus <noreply@anthropic.com>
…e, and a failure of the same unit earlier that day (PLX-253)

New and changed cases of the runner host's mail newborn, ahead of the code:
an item that lacks a field, leaves one empty or names an unknown mode is
no item, and a field on the command line counts; a mail role that fails
fails no run; the disk check mails although the housekeeping mailed that
day; a slot that cannot register mails although its container failed that
day; the row of failed mintings fails towards mailing (a row or a threshold
that is no number, a stop between two attempts, a minting systemd ends for
its time); mail_loopback_smtp opens the port again and closes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r own, with a mail budget of their own (PLX-253)

ci-runner-disk, hourly by its own timer, is the disk check the housekeeping
ran after its pull: a pull that failed earlier the same day no longer takes
the disk's mail, and one that fails for a full disk no longer keeps the
check from running.

ci-runner-cannot-register@<slot>, started by the slot's ExecStopPost after
an attempt that failed, fails once the row of failed mintings is older than
actions_runners_slot_alert_after and says for how long; a container of the
slot that failed earlier the same day takes nothing from its mail. The
slot's own mail is held back for a failed minting alone.

The row fails towards mailing: it holds the host's uptime, which no time
step moves; it is written as an attempt starts, so that one systemd ends
for its time counts; a start that is no restart of systemd's begins a new
one; a row or a threshold that holds no number mails at once and says so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ng mail role leave a host set up and say why it sends no mail (PLX-253)

What is wrong with the mail relay is computed from the variables, so that a
ci_mail_* given on the command line counts, as vars/vault.yml says of every
variable; an empty field counts as missing, and a mode other than starttls
or tls is said. The mail role runs first in the second play, in a block
whose rescue says in the journal what failed, so that a Postfix that cannot
be installed fails no run and stops no slot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ring the line false commented out (PLX-253)

False comments out smtp inet behind a mark of the role's; true restores the
marked line alone, so a line commented out by hand stays. On a host with the
default the file is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…point to vars/vault.yml for its fields (PLX-253)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…PLX-253)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…out mail; the hold says what a held-back minting's mail rests on (PLX-253)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ers/plx-253-every-runner-host-notifies

# Conflicts:
#	templates/repo-operations/files/{% if ci_jobs_strategy == 'byom' %}ci{% endif %}/main.tf.jinja
#	terraform/ci_runner_host_user_data/main.tf
@davidjalbers
davidjalbers merged commit c331eca into plain-pipeline-2 Dec 3, 2026
2 checks passed
@davidjalbers
davidjalbers deleted the davidjalbers/plx-253-every-runner-host-notifies branch December 3, 2026 04:33
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