Tell planned host reboots from crashes instead of only waiting longer #47

Closed
opened 2026-11-16 21:11:19 -05:00 by jared · 2 comments
Owner

Follow-up to #14 / #15.

Problem

#15 stopped planned reboots from cutting "No metrics from host" tickets by waiting host_failure_threshold (5) checks before ticketing a host that has disappeared. That is a time window, not intent detection, so it fails both ways:

  • A planned reboot slower than the window still cuts a ticket. Firmware updates, a slow POST, or a long stopall while guests shut down can all take longer than 5 checks.
  • A crash that recovers inside the window cuts no ticket. The event is recorded, but nobody is told.

The second case has already happened. large1 on 2026-11-14 (UTC):

Time Event
09:32:55 Last journal lines in Loki are routine smartmontools attribute changes
— No systemd-logind "will reboot/power off now", no units stopping, no stopall
~09:34 Prometheus up goes to 0
09:34:51 New boot time
~09:36 up returns to 1

That looks like an unclean reset (crash, watchdog, or power), and it cut no ticket because it was over within the window. It could also be journal lines lost before they shipped; the open questions below cover that.

Signals that are available

Checked against micro1's planned reboot on 2026-11-06 (the one that opened #14):

Signal Where Usable live?
systemd-logind: The system will reboot now! / will power off now! Loki {host="<host>", job="journal", unit="systemd-logind.service"} Yes. It arrived at 23:17:49, about 10s before up went to 0.
Proxmox stopall task (UPID:<host>:…:stopall::root@pam:) Loki {job="pve-tasks", filename="/var/log/pve/tasks/active"} No. It was only ingested after the host came back (23:22 onward), so gandalf can only use it in hindsight.
node_boot_time_seconds changes Prometheus Only after the host returns. It confirms a reboot happened but not whether it was clean.
Missing clean-shutdown lines before the last log line Loki Only after the host returns.

Proposal

  1. When a host disappears, query Loki for a systemd-logind reboot/power-off line from that host in the last few minutes.
    • Found (planned): record the event as a planned reboot and hold off ticketing for a longer planned_reboot_grace (for example 20–30 minutes). Ticket only if the host hasn't come back by then, with wording like "planned reboot of X did not come back".
    • Not found (unplanned): ticket on failure_threshold as before, or keep host_failure_threshold but lower it.
  2. When a host comes back (node_boot_time_seconds changed) and no clean-shutdown line was seen, open a lower-priority "unexpected reboot" ticket even if it was back inside the window. This catches the large1 case.
  3. If Loki is unreachable or returns an error, fall back to the current host_failure_threshold behaviour. Don't silence or speed up alerts because a log query failed.
  4. Show "planned reboot" against the event on the dashboard and event list, so a host that's mid-reboot isn't shown as a plain outage.

Open questions

  • Grace length, and whether it should be per host. Big Ceph/storage nodes take longer to come back.
  • Lost journal lines. Can a clean reboot lose its logind line before it ships, for example if promtail stops first? Check unit ordering on the hosts, and check whether large1's 11-14 journal (journalctl -b -1 -e) shows a clean shutdown that never reached Loki.
  • Priority of the "unexpected reboot" ticket. P3 seems right, since the host recovered.
  • Shared problem with hwmonDaemon. hwmonDaemon tickets also need to recognise an unexpected reboot. Should the detection live in one place, with gandalf owning host-gone or reboot tickets per #2 and LotusGuild/hwmonDaemon#30?

Out of scope

  • Closing tickets automatically when a host recovers (separate follow-up from #14).
  • The cluster_network_issue threshold and suppressions (separate follow-up from #14).

Not being built yet; filed for tracking.

Follow-up to #14 / #15. ## Problem #15 stopped planned reboots from cutting "No metrics from host" tickets by waiting `host_failure_threshold` (5) checks before ticketing a host that has disappeared. That is a time window, not intent detection, so it fails both ways: - **A planned reboot slower than the window still cuts a ticket.** Firmware updates, a slow POST, or a long `stopall` while guests shut down can all take longer than 5 checks. - **A crash that recovers inside the window cuts no ticket.** The event is recorded, but nobody is told. The second case has already happened. **large1 on 2026-11-14 (UTC):** | Time | Event | |---|---| | 09:32:55 | Last journal lines in Loki are routine `smartmontools` attribute changes | | — | No `systemd-logind` "will reboot/power off now", no units stopping, no `stopall` | | ~09:34 | Prometheus `up` goes to 0 | | 09:34:51 | New boot time | | ~09:36 | `up` returns to 1 | That looks like an unclean reset (crash, watchdog, or power), and it cut no ticket because it was over within the window. It could also be journal lines lost before they shipped; the open questions below cover that. ## Signals that are available Checked against micro1's planned reboot on 2026-11-06 (the one that opened #14): | Signal | Where | Usable live? | |---|---|---| | `systemd-logind`: `The system will reboot now!` / `will power off now!` | Loki `{host="<host>", job="journal", unit="systemd-logind.service"}` | **Yes.** It arrived at 23:17:49, about 10s before `up` went to 0. | | Proxmox `stopall` task (`UPID:<host>:…:stopall::root@pam:`) | Loki `{job="pve-tasks", filename="/var/log/pve/tasks/active"}` | **No.** It was only ingested after the host came back (23:22 onward), so gandalf can only use it in hindsight. | | `node_boot_time_seconds` changes | Prometheus | Only after the host returns. It confirms a reboot happened but not whether it was clean. | | Missing clean-shutdown lines before the last log line | Loki | Only after the host returns. | ## Proposal 1. **When a host disappears**, query Loki for a `systemd-logind` reboot/power-off line from that host in the last few minutes. - **Found (planned):** record the event as a planned reboot and hold off ticketing for a longer `planned_reboot_grace` (for example 20–30 minutes). Ticket only if the host hasn't come back by then, with wording like "planned reboot of X did not come back". - **Not found (unplanned):** ticket on `failure_threshold` as before, or keep `host_failure_threshold` but lower it. 2. **When a host comes back** (`node_boot_time_seconds` changed) and no clean-shutdown line was seen, open a lower-priority "unexpected reboot" ticket even if it was back inside the window. This catches the large1 case. 3. **If Loki is unreachable or returns an error**, fall back to the current `host_failure_threshold` behaviour. Don't silence or speed up alerts because a log query failed. 4. Show "planned reboot" against the event on the dashboard and event list, so a host that's mid-reboot isn't shown as a plain outage. ## Open questions - **Grace length**, and whether it should be per host. Big Ceph/storage nodes take longer to come back. - **Lost journal lines.** Can a clean reboot lose its `logind` line before it ships, for example if promtail stops first? Check unit ordering on the hosts, and check whether large1's 11-14 journal (`journalctl -b -1 -e`) shows a clean shutdown that never reached Loki. - **Priority of the "unexpected reboot" ticket.** P3 seems right, since the host recovered. - **Shared problem with hwmonDaemon.** hwmonDaemon tickets also need to recognise an unexpected reboot. Should the detection live in one place, with gandalf owning host-gone or reboot tickets per #2 and LotusGuild/hwmonDaemon#30? ## Out of scope - Closing tickets automatically when a host recovers (separate follow-up from #14). - The `cluster_network_issue` threshold and suppressions (separate follow-up from #14). Not being built yet; filed for tracking.
Author
Owner

Plan agreed 2026-11-25. #47 is split along the ownership lines in the thor README.

Gandalf: #65. This improves the ticket Gandalf already cuts without adding new host-health tickets.

  • Proposal items 1, 3 and 4 are done:
    • When a host disappears, Gandalf asks Loki for a systemd-logind shutdown request.
    • Planned: the host shows as "rebooting (planned)", is kept out of the cluster check, and is ticketed only after planned_reboot_grace (default 20 min, per-host overrides) as "Planned reboot did not come back".
    • No line, or Loki down: alerted as before.
  • Checked against Loki's real data: the last month's 4 planned reboots and power-offs were all recognised, and the 2 unclean stops were not.

Thor: LotusGuild/thor#4. Proposal item 2, the "unexpected reboot" ticket for a crash that recovers inside the window, is new host-health ticketing, so it moves to thor. reboots.py was written so thor can take it over.

Open questions from the issue:

  • Lost journal lines: no evidence so far. Every planned reboot in the last 30 days had its logind line in Loki before the host went quiet. The unclean stops (storage-01 on 11-25, compute-storage-02 on 11-21) show a journal that just stops, with no "Stopping ..." lines either.
  • Grace: 20 min default, per host via planned_reboot_grace_hosts.

This issue closes when #65 merges. The remaining work is tracked in thor#4.

Plan agreed 2026-11-25. #47 is split along the ownership lines in the thor README. **Gandalf: #65.** This improves the ticket Gandalf already cuts without adding new host-health tickets. - Proposal items 1, 3 and 4 are done: - When a host disappears, Gandalf asks Loki for a `systemd-logind` shutdown request. - Planned: the host shows as "rebooting (planned)", is kept out of the cluster check, and is ticketed only after `planned_reboot_grace` (default 20 min, per-host overrides) as "Planned reboot did not come back". - No line, or Loki down: alerted as before. - Checked against Loki's real data: the last month's 4 planned reboots and power-offs were all recognised, and the 2 unclean stops were not. **Thor: LotusGuild/thor#4.** Proposal item 2, the "unexpected reboot" ticket for a crash that recovers inside the window, is new host-health ticketing, so it moves to thor. `reboots.py` was written so thor can take it over. **Open questions from the issue:** - **Lost journal lines:** no evidence so far. Every planned reboot in the last 30 days had its logind line in Loki before the host went quiet. The unclean stops (storage-01 on 11-25, compute-storage-02 on 11-21) show a journal that just stops, with no "Stopping ..." lines either. - **Grace:** 20 min default, per host via `planned_reboot_grace_hosts`. This issue closes when #65 merges. The remaining work is tracked in thor#4.
Author
Owner

#65 is merged and live as of 2026-11-25 14:37 EST.

  • Prod config.json now has loki.url (backup at /root/config.json.bak-2026-11-25-loki).
  • gandalf-monitor was restarted, and prod finds compute-storage-01's 11-25 power-off line through Loki.

Closing. The remaining work, the "unexpected reboot" alert, is LotusGuild/thor#4.

#65 is merged and live as of 2026-11-25 14:37 EST. - Prod `config.json` now has `loki.url` (backup at `/root/config.json.bak-2026-11-25-loki`). - gandalf-monitor was restarted, and prod finds compute-storage-01's 11-25 power-off line through Loki. Closing. The remaining work, the "unexpected reboot" alert, is LotusGuild/thor#4.
jared closed this issue 2026-11-25 14:38:38 -05:00
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: LotusGuild/gandalf#47