From 20e8a2d270df78efd56a80aed64535462aad9818 Mon Sep 17 00:00:00 2001 From: Gerrrt Date: Thu, 19 Nov 2026 12:30:23 -0800 Subject: [PATCH] fix(lab): eden reports patch state, and PatchStateStopped skips it while off Redeploying the lab after #1585 put PatchStateStopped in pending for eden: it stopped reporting at its rebuild on 2026-11-13, because the old guest's timer was installed by hand and build-the-bloodhound-guest.md had no such step. The [1d] window had cleared the alert by 11-14. - The runbook's section 6 installs the patch-state collector; it is installed on eden and the lab reads it. - eden is on-demand (ADR-0079), so the rule's vanished-series branch leaves it out while none of its node metrics have arrived in an hour. A running eden with a dead collector still fires. - promtool: shut-down eden quiet at 3d and 10d, running eden without its collector fires; removing the exclusion fails the first case. Co-Authored-By: Claude Opus 5.5 --- docs/changelog.md | 13 ++++++ docs/runbooks/build-the-bloodhound-guest.md | 19 +++++++++ stacks/lab/prometheus/rules/lab.rules.yaml | 22 ++++++++++ stacks/lab/prometheus/tests/lab.test.yaml | 46 +++++++++++++++++++++ 4 files changed, 100 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index 27d941b4..9b9b210f 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -19,6 +19,19 @@ docstring gives: it is a record, not a claim about now. ## 2026-11-19 +- **`eden` reports its patch state again, and the lab's `PatchStateStopped` + leaves it out while it is off.** Redeploying the lab after #1585 put the + alert in pending for `eden`: it reported from 2026-11-08 until 23:04 UTC on + 2026-11-12 and not since its rebuild the next morning. The old guest's timer + had been installed by hand, `build-the-bloodhound-guest.md` had no such + step, and the `[1d]` window had cleared the alert by 2026-11-14. §6 now + installs it, and it was installed on `eden`. `eden` is `on-demand` and off + between sessions, so the rule's vanished-series branch leaves it out while + none of its node metrics have arrived in an hour: ADR-0079's decision for + `HypervisorGuestStopped`, brought to the lab, which cannot read `Saruman`'s + tags and names the guest instead. Two promtool cases: an `eden` that is + shut down is quiet at 3 d and 10 d, and an `eden` that is running without + its collector fires. - **`PatchStateStopped` and `GuestStateStopped` now also fire for a collector that stops and leaves its file.** The entry below left this open: a stopped timer leaves its `.prom` file in the textfile directory, diff --git a/docs/runbooks/build-the-bloodhound-guest.md b/docs/runbooks/build-the-bloodhound-guest.md index 12b259ad..009ed54b 100644 --- a/docs/runbooks/build-the-bloodhound-guest.md +++ b/docs/runbooks/build-the-bloodhound-guest.md @@ -405,6 +405,25 @@ Check each one now: there means the leaf lacks the `bloodhound` SAN. §7's `up{job="bloodhound"}` is the same answer from `alexander`. +**Report patch state**, so a held security update or a pending reboot reaches +someone while the guest runs. The lab's `SecurityUpdatesPending`, +`RebootRequired` and `PatchStateStopped` read `apt-patch-state.prom`, and a +guest without the timer is invisible to all three. Until 2026-11-19 this step +was missing: the guest reported until its rebuild on 2026-11-13, from a timer +put there by hand, and not after. `make up` has created the textfile +directory. From the checkout on Hicks, logged in as `garnet`; the installer +asks for its sudo password once: + +```bash +make install-agent-collectors AGENT=garnet@10.0.30.41 ARGS='--only patch-state' +``` + +It must end with `apt-patch-state.prom written, mode 644`. The timer is +`Persistent=true`, so a run missed while the guest was off happens at its next +boot. `PatchStateStopped` names `eden` as on-demand and leaves it out while +none of its node metrics arrive (ADR-0079's reasoning), so shutting it down is +not an alert; a dead collector on a running `eden` still is. + Then shut it down cleanly. That is what "off between sessions" means, and the first session should start from it: diff --git a/stacks/lab/prometheus/rules/lab.rules.yaml b/stacks/lab/prometheus/rules/lab.rules.yaml index 9e1779cb..6c25017a 100644 --- a/stacks/lab/prometheus/rules/lab.rules.yaml +++ b/stacks/lab/prometheus/rules/lab.rules.yaml @@ -275,12 +275,34 @@ groups: # daily timer, covers one missed run and its jitter. The mtime series # carries `instance`, not `host`, so label_replace copies one into the # other. Raised in review on #1544. + # + # ON-DEMAND GUESTS ARE LEFT OUT WHILE THEY ARE OFF, which is ADR-0079's + # decision for HypervisorGuestStopped brought to this rule. `eden` is off + # between sessions, and an off guest pushes nothing, so without this the + # first branch fires six hours after every session ends. The lab cannot + # read Saruman's `on-demand` tag, so the guests are named here, as + # `role="endpoint"` names the domain's in prometheus.yaml: add a Linux + # guest here when it gets the tag and the collector. "Off" is "none of + # its node metrics have arrived in an hour", read from + # node_boot_time_seconds, which every guest's Alloy pushes; a window, not + # an instant, so a late push does not count as a shutdown, and an hour + # is well inside the six hours the branch waits anyway. While the guest is up it is treated like any + # other, so a dead collector on a running `eden` still fires. Only the + # first branch needs this: an off guest's mtime series goes with it, and + # at boot Persistent=true collects within the timer's 15 minutes of jitter, + # inside `for: 30m`. - alert: PatchStateStopped expr: >- ( count by (host) (present_over_time(homelab_apt_upgrades_pending[14d] offset 6h)) unless count by (host) (present_over_time(homelab_apt_upgrades_pending[6h])) + unless on (host) + ( + count by (host) (present_over_time(homelab_apt_upgrades_pending{host=~"eden"}[14d] offset 6h)) + unless + count by (host) (present_over_time(node_boot_time_seconds{host=~"eden"}[1h])) + ) ) or count by (host) ( diff --git a/stacks/lab/prometheus/tests/lab.test.yaml b/stacks/lab/prometheus/tests/lab.test.yaml index 30a8e49c..eb20c5ed 100644 --- a/stacks/lab/prometheus/tests/lab.test.yaml +++ b/stacks/lab/prometheus/tests/lab.test.yaml @@ -923,6 +923,52 @@ tests: alertname: PatchStateStopped exp_alerts: [] + # --- PatchStateStopped: quiet for an on-demand guest that is off ---------- + # ADR-0079 for this rule. `eden` reports for 20 hours, then is shut down: + # its patch state and its node metrics stop together. Quiet at 3d and 10d. + - interval: 1h + input_series: + - series: 'homelab_apt_upgrades_pending{host="eden"}' + values: "0x20 _x250" + - series: 'node_boot_time_seconds{host="eden"}' + values: "1x20 _x250" + alert_rule_test: + - eval_time: 3d + alertname: PatchStateStopped + exp_alerts: [] + - eval_time: 10d + alertname: PatchStateStopped + exp_alerts: [] + + # --- PatchStateStopped: fires for an on-demand guest that is up ------------ + # The same `eden`, booted again on day 2 with its collector gone: node + # metrics arrive and patch state does not. That is a dead collector on a + # running guest, and it must fire like any other guest's. + - interval: 1h + input_series: + - series: 'homelab_apt_upgrades_pending{host="eden"}' + values: "0x20 _x250" + - series: 'node_boot_time_seconds{host="eden"}' + values: "1x20 _x28 2x220" + alert_rule_test: + - eval_time: 3d + alertname: PatchStateStopped + exp_alerts: + - exp_labels: + host: eden + component: host + severity: warning + category: security + exp_annotations: + summary: "eden has stopped reporting patch state" + description: >- + Its patch state has gone absent, or apt-patch-state.prom has not + been rewritten in two days, so SecurityUpdatesPending and + RebootRequired are reading stale or no data for it. Check + `systemctl status homelab-patch-state.timer` on the guest, and that + /var/lib/node_exporter/textfile_collector/apt-patch-state.prom is + being written and is world-readable. + # --- PatchStateStopped: quiet for a guest that reports zero ---------------- - interval: 5m input_series: