This is a planning session, to be done before any code. The README has the charter and the boundaries between the three apps.
Questions to settle
Where it runs. It must be off the cluster nodes, and preferably on a different box from Gandalf. Decide what it monitors itself with: who watches Thor?
Data sources and cadence.
Prometheus queries: node_vmstat_oom_kill, memory and pressure (PSI), up and scrape_duration, Ceph exporter metrics.
Loki: the kernel lines for OOM kills, which name the guest.
The Proxmox API: HA, guests and storage.
Ceph status.
Ticket contract between the three apps.
A shared incident key.
The rule for checking for an open ticket before cutting a new one.
How each app tags its tickets.
Auto-resolve notes.
How a Thor root-cause ticket absorbs symptom tickets from the other two.
Root-cause grouping. For example, an OOM on a host plus Ceph slow ops plus scrape timeouts cluster-wide should produce one ticket: "compute-storage-01 out of memory (CT 154)".
Migration order from hwmonDaemon (#39, #40): memory, CPU, LXC storage, Ceph. Include how to switch each check off in hwmonDaemon without leaving a gap.
Stack. Reuse Gandalf's patterns (Flask + MariaDB + monitor loop, the Tinker client), or keep Thor headless with no UI?
Tests. A replay of 2026-11-23 06:01 should produce exactly one correct ticket across all three apps.
Reference incident
Tinker 615797777, gandalf#57 and hwmonDaemon#39.
This is a planning session, to be done before any code. The README has the charter and the boundaries between the three apps.
## Questions to settle
1. **Where it runs.** It must be off the cluster nodes, and preferably on a different box from Gandalf. Decide what it monitors itself with: who watches Thor?
2. **Data sources and cadence.**
- Prometheus queries: `node_vmstat_oom_kill`, memory and pressure (PSI), `up` and `scrape_duration`, Ceph exporter metrics.
- Loki: the kernel lines for OOM kills, which name the guest.
- The Proxmox API: HA, guests and storage.
- Ceph status.
3. **Ticket contract between the three apps.**
- A shared incident key.
- The rule for checking for an open ticket before cutting a new one.
- How each app tags its tickets.
- Auto-resolve notes.
- How a Thor root-cause ticket absorbs symptom tickets from the other two.
4. **Root-cause grouping.** For example, an OOM on a host plus Ceph slow ops plus scrape timeouts cluster-wide should produce one ticket: "compute-storage-01 out of memory (CT 154)".
5. **Migration order from hwmonDaemon** (#39, #40): memory, CPU, LXC storage, Ceph. Include how to switch each check off in hwmonDaemon without leaving a gap.
6. **Stack.** Reuse Gandalf's patterns (Flask + MariaDB + monitor loop, the Tinker client), or keep Thor headless with no UI?
7. **Tests.** A replay of 2026-11-23 06:01 should produce exactly one correct ticket across all three apps.
## Reference incident
Tinker 615797777, gandalf#57 and hwmonDaemon#39.
Don't open new tickets for it. If anything, add notes to that ticket.
It sits outside the rack and isn't on the rack UPS.
Ceph noout: set on purpose, long-term, because of compute-storage-02. A "maintenance flag left on" check therefore needs an acknowledge or known-condition mechanism (for example, linked to the tracking ticket), not a fixed time limit.
Lessons from real incidents
2026-11-23 (Tinker 615797777): an OOM loop on compute-storage-01 (CT 154) stalled Ceph and timed out scrapes on three hosts. Gandalf wrongly opened a P1 network ticket (fixed in gandalf#57). This is the replay test in item 7 above.
2026-11-24 evening (03:10 to 03:35 UTC on 11-25), planned rack maintenance:
What the operator did:
Silenced Gandalf and paused Ceph.
Started host shutdowns.
Updated the UniFi switches, which rebooted the network.
Updated the UPS firmware, knowing beforehand that the update would cut power to the rack.
The power cut was planned and expected, not a surprise outage.
What it means for thor:
Journals stopped reaching Loki about 20 minutes before the hosts lost power, when the switches went down.
## Handoff brief for the planning session (2026-11-25)
This collects what the Gandalf sessions learned that Thor's planning needs. It's here so a fresh session can start from it.
### Ownership rule (decided 2026-11-23)
| App | Owns |
|---|---|
| **gandalf** | The network only. It must not open memory or host-health tickets. |
| **hwmonDaemon** | Only what the host alone can read: SMART, ECC, the hardware event log. |
| **thor** | Anything visible from Prometheus, Loki, Proxmox or Ceph, with one ticket per root cause. |
Routing rule for new checks: if node_exporter or Loki exposes it, it's thor; if only the box knows, it's hwmonDaemon; if it's network, it's gandalf.
### Data sources (all verified working)
- **Prometheus:** `http://10.10.10.48:9090`.
- node_exporter runs on every host.
- `node_boot_time_seconds`, `node_vmstat_oom_kill`, `up` and `scrape_duration_seconds` all work.
- **Loki:** `http://10.10.10.69:3100`.
- Journals use `{job="journal", host="<host>", unit="<unit>"}`, and the `host` label matches Gandalf's host names.
- Proxmox tasks are under `{job="pve-tasks"}`, but they're only ingested after a host comes back.
- Queries over 30 days are rejected.
- `/ready` can return 503 while queries still work.
- **Ceph exporter:** `10.10.10.4:9283`.
- `ceph_health_status`, `ceph_health_detail{name,severity}` (e.g. OSDMAP_FLAGS, RECENT_CRASH, BLUESTORE_SLOW_OP_ALERT) and `ceph_osd_flag_*`.
- The `pause` flags aren't exported, so read them from `ceph osd dump`.
- **Hosts:**
| Host | Address |
|---|---|
| compute-storage-01 | .4 |
| compute-storage-02 | .2 |
| compute-storage-gpu-01 | .10 |
| storage-01 | .11 |
| monitor-01 | .8 |
| monitor-02 | .9 |
| pbs | .3 |
- Renames: large1 is now compute-storage-02 and micro1 is now monitor-01. Older Loki lines use the old names.
### Code thor can lift from gandalf
- `reboots.py` (gandalf#65): the Loki client, `find_shutdown`, and planned-reboot grace.
- Ticket client and ticket text, with the title-tag format `[host][auto][production][issue][...]`.
- gandalf#57's rule: never call it a network fault without network evidence.
### Known conditions thor must handle (operator decisions)
- **compute-storage-02:** it reboots every 2 to 3 days from a known failing DIMM (P0 Channel B DIMM 1, ECC errors).
- Tracked in Tinker [693930698](https://t.lotusguild.org/ticket/693930698).
- Don't open new tickets for it. If anything, add notes to that ticket.
- It sits outside the rack and isn't on the rack UPS.
- **Ceph `noout`:** set on purpose, long-term, because of compute-storage-02. A "maintenance flag left on" check therefore needs an acknowledge or known-condition mechanism (for example, linked to the tracking ticket), not a fixed time limit.
### Lessons from real incidents
- **2026-11-23 (Tinker 615797777):** an OOM loop on compute-storage-01 (CT 154) stalled Ceph and timed out scrapes on three hosts. Gandalf wrongly opened a P1 network ticket (fixed in gandalf#57). This is the replay test in item 7 above.
- **2026-11-24 evening (03:10 to 03:35 UTC on 11-25), planned rack maintenance:**
- What the operator did:
1. Silenced Gandalf and paused Ceph.
2. Started host shutdowns.
3. Updated the UniFi switches, which rebooted the network.
4. Updated the UPS firmware, knowing beforehand that the update would cut power to the rack.
- The power cut was planned and expected, not a surprise outage.
- What it means for thor:
- Journals stopped reaching Loki about 20 minutes before the hosts lost power, when the switches went down.
- Thor needs maintenance awareness: Gandalf silences, Ceph flags, firmware updates.
- A journal that went quiet before the host did means "unknown", not "crash".
- Group simultaneous reboots into one event. See #4.
### Operator preferences (apply everywhere)
- **No em or en dashes**, anywhere: UI, code, commits, PRs, tickets, replies. Use hyphens, colons, commas or pipes.
- **Never mark something unused or suppress an alert on your own diagnosis.** Ask first.
- **UI:** the top concern is avoiding overload. Fold new problems into one "Needs attention" style list rather than adding new sections.
- **Merges:** the operator says "merge N". After merging, verify the deploy: prod HEAD, the services active, health 200, and no tracebacks.
### Open thor issues
- #2: hardware registry keyed by serial number, linked to HomeBox.
- #3: detailed Ceph view.
- #4: unexpected-reboot alerts.
Thor plan: decisions from the 2026-11-25 planning session
Context
On 2026-11-23 an OOM loop on compute-storage-01 (CT 154) stalled Ceph cluster-wide. hwmonDaemon on that host saw nothing, and Gandalf opened a false P1 network ticket (Tinker 615797777, fixed in gandalf#57). Thor is the out-of-band host and cluster health app: it owns anything visible from Prometheus, Loki, Proxmox or Ceph, and opens one ticket per root cause. thor#1 asked seven questions; this session answered all of them with the operator, testing every choice against real incidents. No code was written. The follow-up issues and wiki changes are listed at the end.
Test cases (used for every decision)
Case
What happened (UTC)
Right outcome
T1 2026-11-23 OOM
11 global OOM kills of CT 154's Java on compute-storage-01 from 05:11:08; 06:01:27 kill from the ceph-osd slice; pvestatd timeouts everywhere; Loki 500s; scrapes of 4 hosts 5-10 s, 3 timed out
1 ticket [compute-storage-01][auto][thor][software] Out of memory: CT 154 ..., P3 ~05:15, P2 ~05:20, P1 06:01. Ceph slow ops, pvestatd and scrape timeouts are "Also seen". 673679581 listed as related. Gandalf: no ticket
T2 2026-11-25 planned rack maintenance
Gandalf silenced; Ceph pause via Proxmox UI (task 03:12:10, only visible in pve-tasks, ingested ~03:26); switches down ~03:11; clean logind power-off cs-01/cs-02 03:21:35; UPS firmware cut rack power ~03:25-03:32; Prometheus has no samples 03:16-03:38; no Kuma window, no Grafana silence
0 tickets. Thor timeline entry; ticket only if something stayed down
T3 2026-10-27
cs-01's only corosync link down ~15:53 (5 nodes kept quorum), HA fenced it, reboot; hwmonDaemon then opened ~12 tickets in one second (mons down, host down, one per OSD)
1 ticket "compute-storage-01 lost its cluster link and was fenced" (P2); hwmonDaemon's reports answered "covered"
T4 2026-11-04
corosync link 0 down between many nodes ~20:51; cs-01 and gpu-01 each alone in a non-primary component, watchdog expired, both self-fenced (twice that day); mons down, 47 PGs inactive
1 ticket for the partition (P1), Gandalf's if it had network evidence
Extra
compute-storage-02 DIMM reboot 2026-11-21 ~03:24
0 tickets, 1 note on 693930698
Since 2026-11-18 corosync has two knet links (10.10.10.x priority 20, 10.10.90.x priority 10), which is the fix for T3/T4.
1. Where Thor runs and who watches it
HA LXC on the cluster, like Gandalf, in the EMERGENCY needed node-affinity rule (BMC servers: compute-storage-01:1, compute-storage-02:2, storage-01:2). The operator accepted the risk after seeing the strict investigation-tools rule (never cs-01/cs-02, holds Kuma, Grafana, Prometheus, Tinker, Loki). Real independence comes with 3+ racks later.
State: shared MariaDB CT 149, schema thor.
No out-of-band notification: queue and send when Tinker returns. Paging app / external probe are future work.
Watching Thor: Kuma probes /health (503 when the monitor loop is stale, like Gandalf's health() in app.py); Prometheus scrapes a Thor heartbeat metric with a Grafana staleness rule.
Design rules because Thor lives on what it watches:
Decide from history, not live edges: every cycle covers the window since the last good one using lasting evidence (node_vmstat_oom_kill, node_boot_time_seconds, Loki lines).
Read maintenance signals from history (in T2, pause was set during the switch outage and cleared before Thor was back).
"Blind since X" is its own state, never "host down"; Thor survives DB and Tinker outages without losing what it saw.
Outbox: tickets and notes queue while Tinker is unreachable, posted with original times.
24 h catch-up after Thor's own downtime, summarised once as "seen after the fact".
No direct host probes: Thor uses Gandalf's reachability data via Gandalf's HTTP API with a read-only machine key; anything that must run on a host goes through Pulse.
2. Ticket contract (gandalf, hwmonDaemon, thor)
Ownership by evidence domain (README rule). Added: Thor owns corosync link loss, quorum loss and fencing, and monitoring-source-down tickets (Prometheus, Loki), unless Gandalf has an active network incident covering it.
The root cause owns the ticket, whichever app found it. Symptoms are "Also seen" comments. Thor is the only correlator.
Dedupe: the app chooses the key, Tinker enforces it (dedup_key, format scope:subject:kind, e.g. host:compute-storage-01:oom, cluster:ceph:BLUESTORE_SLOW_OP_ALERT, site:rack1:power). Only the owner writes the description; others comment.
Pre-check: before a host-, cluster- or source-level ticket, Gandalf and hwmonDaemon call Thor GET /api/incidents/covering?host=X (or scope=). Covered: comment on Thor's ticket. Thor down or slow: open as normal (fail open). The same call reports known conditions.
Standing tickets (e.g. 673679581) are listed in a "Related open tickets" section only.
Resolve: "Cleared" note only (Gandalf style), after 15 minutes clean; no app changes ticket status. hwmonDaemon starts adding clear notes.
Recurrence, same for all three apps, enforced by Tinker: reopen if closed under 7 days ago, otherwise a new ticket linked to the old one with history.
App identity: Tinker records the API key name as creator, a footer names the app, and titles carry an app tag: [source][auto][app][area] Summary [scope][environment][type] with [gandalf], [hwmon], [thor]. Checked against helpers/TicketHash.php: the tag and Gandalf's tag reorder change no existing hash.
Known conditions live in Thor (UI + MCP), each tied to its tracking ticket and ending when that ticket closes. First entries: compute-storage-02 reboots and Ceph noout -> 693930698; the old UPS battery (two Grafana silences until 2029).
Maintenance is declared once, in Gandalf, which fans out to a Kuma window and a Grafana silence (gandalf#67). Thor reads suppressions with start/end times; Ceph pause, nut_ups_on_battery, UniFi firmware events and logind lines are backup signals.
Loki (10.10.10.69): on demand when a Prometheus signal fires, plus a 5 min sweep for kernel OOM (transport="kernel", gives global_oom, cpuset, task_memcg=/lxc/<id>), logind shutdown, corosync link/quorum, watchdog, and pve-tasks (use the UPID start time, not ingest time). A failed query retries, never "nothing found".
Proxmox API: read-only token thor@pve (PVEAuditor), tried across nodes: /cluster/ceph/flags (includes pause), /cluster/ceph/status, /cluster/ha/status/current, /cluster/status (node names and IPs), guests and storage.
Ceph CLI for thor#3 (ok-to-stop, safe-to-destroy, pg ls-by-osd): read-only via Pulse.
Grafana: independent; Thor doesn't read its alerts.
Host names: from the Proxmox API plus an alias table (micro1, large1); match Prometheus by IP (cs-02's job is still largeoneexporter).
4. Root-cause grouping
Precedence: maintenance > site power > network (Gandalf) > corosync partition / fencing > host down or unexpected reboot > host resource exhaustion > Ceph symptoms > scrape/pvestatd timeouts. Symptoms attach when they start within the cause's window and share a host or are cluster-wide.
Timing: hold a new finding one more cycle, then open; later signals become comments.
OOM: global OOM -> ticket at first kill (P3), 3+ in 30 min P2, hitting Ceph P1. Cgroup OOM -> shown in Thor, ticket only if it loops.
Priorities: P1 data availability (PGs inactive/down, HEALTH_ERR, quorum lost, 2+ hosts down unplanned, OOM hitting Ceph); P2 one host down/fenced, OOM loop, cluster-wide slow ops, source down, guest crash-loop; P3 recovered unexpected reboot, single global OOM, guest storage threshold; P4 standing (CPU pressure, overdue scrubs, lingering flags); P5 not ticketed.
Reboots within 15 minutes are one event ("grouped by time" in the text).
Maintenance summary: Thor timeline only; ticket only if something didn't recover.
Memory overcommit (guest limits + OSD targets vs RAM): shown in Thor and on OOM tickets, no ticket.
CPU: PSI node_pressure_cpu_waiting_seconds_total sustained for an hour, P4.
5. Migration from hwmonDaemon
Order: memory, Ceph, LXC storage, CPU.
Per check: shadow in Thor ("would open" logged, nothing to Tinker) -> go live when the replays pass and the operator OKs the shadow output -> in one change Thor goes live, adopts the tickets, and hwmonDaemon's switch for that check goes off.
hwmonDaemon#39: skipped, closed as superseded; no OOM ticketing until Thor ships (accepted).
Open tickets: Thor adopts the Ceph ones (673679581, 629475198, 534304596, 510172934) via the dedup_key backfill; the old CPU P4s get a "rule retired" note and the operator closes them.
LXC storage: rootfs from the Proxmox API each cycle; mount points from read-only pct df via Pulse every 15 min; the Sia hostd rule (CT 141) becomes a per-volume exception in Thor.
hwmonDaemon network checks move to Gandalf and are switched off in hwmonDaemon once covered.
MCP v1 (in-app, https://thor.lotusguild.org/mcp, Authelia client thor-mcp, two_factor, scopes thor:read/thor:write, per the wiki checklist; callback port 47826 or 47827, whichever the Gandalf MCP session doesn't take): read incidents, timeline, blind periods, maintenance, known conditions, "what would Thor do"; write known conditions and symptom attach/detach.
No beta instance; shadow mode + CI replays instead.
LXC checklist: 2 cores / 1 GB / 8 GB appPool, unprivileged, nesting+keyctl, DHCP (operator adds the reservation), apt proxy via /usr/local/bin/apt-proxy-detect.sh -> CT 135 10.10.10.55:3142 installed by hand, HA rule EMERGENCY needed, NPM thor.lotusguild.org with Authelia two_factor group admin and the /mcp exemptions, Kuma monitor, Prometheus scrape + Grafana staleness rule, PatchMon agent, deploy from LotusGuild/thor via signed Gitea webhook, post-merge check (prod HEAD, services active, /health 200, no tracebacks).
7. Tests
Fixtures in the repo, trimmed: only the series/lines Thor queries for T1-T4 and the DIMM reboot, as JSON, with usernames and unrelated content scrubbed.
Replays: fake clock, fake Tinker, fake Gandalf API; feed the recorded windows; assert the table above, including that every report Gandalf and hwmonDaemon would have made gets "covered" from /covering.
CI on every PR in Gitea Actions, modelled on Pulse's ci.yml: lint (ruff/flake8) + no em/en dash check; pytest with coverage; the replays (a changed ticket count fails the PR); bandit + semgrep; pip-audit, licence check, CycloneDX SBOM artifact; integration job with a MariaDB service and fake upstreams (contract tests for /covering and the Tinker payload, like Pulse's Gandalf contract tests; MCP token validation against a test JWKS); gitleaks, actionlint, zizmor, shellcheck; web_template drift check; Playwright for the UI.
Follow-up issues and changes
LotusGuild/tinker_tickets#123: dedup_key, key lookup, link API, creator attribution, 7 day reopen window, per-app backfill.
LotusGuild/gandalf#66: Gandalf's side of the contract ([gandalf] tag, machine-key read API for Thor, pre-check /covering, dedup_key, source-down handoff, takes over hwmonDaemon's network checks).
LotusGuild/gandalf#67: maintenance fan-out (one Gandalf maintenance also opens a Kuma window and a Grafana silence, each with its own end time).
hwmonDaemon#39 closed as superseded: memory is Thor's first check.
Wiki: title standard updated on the Tinker pages; corosync gotcha on the cluster overview fixed (two knet links since 2026-11-18).
Not done: README update, Thor phase issues, code.
Verification (for the build)
The Area 7 CI suite, especially the T1-T4 replays producing exactly the outcomes in the test-case table.
Each migration's shadow output reviewed by the operator before go-live.
# Thor plan: decisions from the 2026-11-25 planning session
## Context
On 2026-11-23 an OOM loop on compute-storage-01 (CT 154) stalled Ceph cluster-wide. hwmonDaemon on that host saw nothing, and Gandalf opened a false P1 network ticket (Tinker 615797777, fixed in gandalf#57). Thor is the out-of-band host and cluster health app: it owns anything visible from Prometheus, Loki, Proxmox or Ceph, and opens one ticket per root cause. thor#1 asked seven questions; this session answered all of them with the operator, testing every choice against real incidents. No code was written. The follow-up issues and wiki changes are listed at the end.
## Test cases (used for every decision)
| Case | What happened (UTC) | Right outcome |
|---|---|---|
| **T1** 2026-11-23 OOM | 11 global OOM kills of CT 154's Java on compute-storage-01 from 05:11:08; 06:01:27 kill from the ceph-osd slice; pvestatd timeouts everywhere; Loki 500s; scrapes of 4 hosts 5-10 s, 3 timed out | 1 ticket `[compute-storage-01][auto][thor][software] Out of memory: CT 154 ...`, P3 ~05:15, P2 ~05:20, P1 06:01. Ceph slow ops, pvestatd and scrape timeouts are "Also seen". 673679581 listed as related. Gandalf: no ticket |
| **T2** 2026-11-25 planned rack maintenance | Gandalf silenced; Ceph `pause` via Proxmox UI (task 03:12:10, only visible in `pve-tasks`, ingested ~03:26); switches down ~03:11; clean logind power-off cs-01/cs-02 03:21:35; UPS firmware cut rack power ~03:25-03:32; Prometheus has no samples 03:16-03:38; no Kuma window, no Grafana silence | 0 tickets. Thor timeline entry; ticket only if something stayed down |
| **T3** 2026-10-27 | cs-01's only corosync link down ~15:53 (5 nodes kept quorum), HA fenced it, reboot; hwmonDaemon then opened ~12 tickets in one second (mons down, host down, one per OSD) | 1 ticket "compute-storage-01 lost its cluster link and was fenced" (P2); hwmonDaemon's reports answered "covered" |
| **T4** 2026-11-04 | corosync link 0 down between many nodes ~20:51; cs-01 and gpu-01 each alone in a non-primary component, watchdog expired, both self-fenced (twice that day); mons down, 47 PGs inactive | 1 ticket for the partition (P1), Gandalf's if it had network evidence |
| Extra | compute-storage-02 DIMM reboot 2026-11-21 ~03:24 | 0 tickets, 1 note on 693930698 |
Since 2026-11-18 corosync has two knet links (10.10.10.x priority 20, 10.10.90.x priority 10), which is the fix for T3/T4.
## 1. Where Thor runs and who watches it
- **HA LXC on the cluster, like Gandalf**, in the `EMERGENCY needed` node-affinity rule (BMC servers: compute-storage-01:1, compute-storage-02:2, storage-01:2). The operator accepted the risk after seeing the strict `investigation-tools` rule (never cs-01/cs-02, holds Kuma, Grafana, Prometheus, Tinker, Loki). Real independence comes with 3+ racks later.
- **State:** shared MariaDB CT 149, schema `thor`.
- **No out-of-band notification:** queue and send when Tinker returns. Paging app / external probe are future work.
- **Watching Thor:** Kuma probes `/health` (503 when the monitor loop is stale, like Gandalf's `health()` in `app.py`); Prometheus scrapes a Thor heartbeat metric with a Grafana staleness rule.
- **Design rules because Thor lives on what it watches:**
1. Decide from history, not live edges: every cycle covers the window since the last good one using lasting evidence (`node_vmstat_oom_kill`, `node_boot_time_seconds`, Loki lines).
2. Read maintenance signals from history (in T2, `pause` was set during the switch outage and cleared before Thor was back).
3. "Blind since X" is its own state, never "host down"; Thor survives DB and Tinker outages without losing what it saw.
4. Outbox: tickets and notes queue while Tinker is unreachable, posted with original times.
5. **24 h catch-up** after Thor's own downtime, summarised once as "seen after the fact".
- **No direct host probes:** Thor uses Gandalf's reachability data via **Gandalf's HTTP API with a read-only machine key**; anything that must run on a host goes through Pulse.
## 2. Ticket contract (gandalf, hwmonDaemon, thor)
- **Ownership by evidence domain** (README rule). Added: Thor owns corosync link loss, quorum loss and fencing, and monitoring-source-down tickets (Prometheus, Loki), unless Gandalf has an active network incident covering it.
- **The root cause owns the ticket, whichever app found it.** Symptoms are "Also seen" comments. Thor is the only correlator.
- **Dedupe: the app chooses the key, Tinker enforces it** (`dedup_key`, format `scope:subject:kind`, e.g. `host:compute-storage-01:oom`, `cluster:ceph:BLUESTORE_SLOW_OP_ALERT`, `site:rack1:power`). Only the owner writes the description; others comment.
- **Pre-check:** before a host-, cluster- or source-level ticket, Gandalf and hwmonDaemon call Thor `GET /api/incidents/covering?host=X` (or `scope=`). Covered: comment on Thor's ticket. Thor down or slow: open as normal (fail open). The same call reports known conditions.
- **Absorbing another app's symptom ticket:** comment "Root cause: #X" + `relates_to` link; operator closes.
- **Standing tickets** (e.g. 673679581) are listed in a "Related open tickets" section only.
- **Resolve:** "Cleared" note only (Gandalf style), after **15 minutes clean**; no app changes ticket status. hwmonDaemon starts adding clear notes.
- **Recurrence, same for all three apps, enforced by Tinker:** reopen if closed under 7 days ago, otherwise a new ticket linked to the old one with history.
- **App identity:** Tinker records the API key name as creator, a footer names the app, and titles carry an app tag: `[source][auto][app][area] Summary [scope][environment][type]` with `[gandalf]`, `[hwmon]`, `[thor]`. Checked against `helpers/TicketHash.php`: the tag and Gandalf's tag reorder change no existing hash.
- **Known conditions live in Thor** (UI + MCP), each tied to its tracking ticket and ending when that ticket closes. First entries: compute-storage-02 reboots and Ceph `noout` -> 693930698; the old UPS battery (two Grafana silences until 2029).
- **Maintenance is declared once, in Gandalf**, which fans out to a Kuma window and a Grafana silence (gandalf#67). Thor reads suppressions with start/end times; Ceph `pause`, `nut_ups_on_battery`, UniFi firmware events and logind lines are backup signals.
## 3. Data sources and cadence
- **Main loop 120 s** (same as Gandalf).
- **Prometheus** (10.10.10.48, retention 1 y): `node_vmstat_oom_kill`, PSI `node_pressure_*`, `node_memory_*`, `up`, `scrape_duration_seconds`, `ceph_health_detail`, `ceph_mon_quorum_status`, `ceph_osd_{up,in}`, `ceph_osd_flag_*`, `ceph_pg_*`, `nut_*`.
- **Loki** (10.10.10.69): on demand when a Prometheus signal fires, plus a 5 min sweep for kernel OOM (`transport="kernel"`, gives `global_oom`, `cpuset`, `task_memcg=/lxc/<id>`), logind shutdown, corosync link/quorum, watchdog, and `pve-tasks` (use the UPID start time, not ingest time). A failed query retries, never "nothing found".
- **Proxmox API:** read-only token `thor@pve` (PVEAuditor), tried across nodes: `/cluster/ceph/flags` (includes `pause`), `/cluster/ceph/status`, `/cluster/ha/status/current`, `/cluster/status` (node names and IPs), guests and storage.
- **Ceph CLI** for thor#3 (ok-to-stop, safe-to-destroy, pg ls-by-osd): read-only via Pulse.
- **Gandalf API:** status, suppressions (incl. ended), events, attention.
- **Grafana:** independent; Thor doesn't read its alerts.
- **Host names:** from the Proxmox API plus an alias table (`micro1`, `large1`); match Prometheus by IP (cs-02's job is still `largeoneexporter`).
## 4. Root-cause grouping
- **Precedence:** maintenance > site power > network (Gandalf) > corosync partition / fencing > host down or unexpected reboot > host resource exhaustion > Ceph symptoms > scrape/pvestatd timeouts. Symptoms attach when they start within the cause's window and share a host or are cluster-wide.
- **Timing:** hold a new finding one more cycle, then open; later signals become comments.
- **OOM:** global OOM -> ticket at first kill (P3), 3+ in 30 min P2, hitting Ceph P1. Cgroup OOM -> shown in Thor, ticket only if it loops.
- **Priorities:** P1 data availability (PGs inactive/down, HEALTH_ERR, quorum lost, 2+ hosts down unplanned, OOM hitting Ceph); P2 one host down/fenced, OOM loop, cluster-wide slow ops, source down, guest crash-loop; P3 recovered unexpected reboot, single global OOM, guest storage threshold; P4 standing (CPU pressure, overdue scrubs, lingering flags); P5 not ticketed.
- **Reboots within 15 minutes** are one event ("grouped by time" in the text).
- **Maintenance summary:** Thor timeline only; ticket only if something didn't recover.
- **Memory overcommit** (guest limits + OSD targets vs RAM): shown in Thor and on OOM tickets, no ticket.
- **CPU:** PSI `node_pressure_cpu_waiting_seconds_total` sustained for an hour, P4.
## 5. Migration from hwmonDaemon
- **Order:** memory, Ceph, LXC storage, CPU.
- **Per check:** shadow in Thor ("would open" logged, nothing to Tinker) -> go live when the replays pass and the operator OKs the shadow output -> in one change Thor goes live, adopts the tickets, and hwmonDaemon's switch for that check goes off.
- **hwmonDaemon#39:** skipped, closed as superseded; no OOM ticketing until Thor ships (accepted).
- **Open tickets:** Thor adopts the Ceph ones (673679581, 629475198, 534304596, 510172934) via the dedup_key backfill; the old CPU P4s get a "rule retired" note and the operator closes them.
- **LXC storage:** rootfs from the Proxmox API each cycle; mount points from read-only `pct df` via Pulse every 15 min; the Sia hostd rule (CT 141) becomes a per-volume exception in Thor.
- **hwmonDaemon network checks** move to Gandalf and are switched off in hwmonDaemon once covered.
## 6. Stack and deployment
- Python, Gandalf's pattern: `thor.service` (Flask/gunicorn: UI, API, MCP) + `thor-monitor.service`; `web_template` terminal look; one "Needs attention" list.
- **Copy** Gandalf's `reboots.py` (Loki client, `find_shutdown`), `TicketClient`, `ticket_text` into Thor, crediting the source commit; shared package later.
- **Phases:** 1 core (incidents, contract, `/covering`, known conditions, memory, MCP v1) + thor#4 reboots; 2 Ceph migration + thor#3 view; 3 thor#2 drive registry (needs hwmonDaemon#41); then LXC storage and CPU.
- **MCP v1** (in-app, `https://thor.lotusguild.org/mcp`, Authelia client `thor-mcp`, `two_factor`, scopes `thor:read`/`thor:write`, per the wiki checklist; callback port 47826 or 47827, whichever the Gandalf MCP session doesn't take): read incidents, timeline, blind periods, maintenance, known conditions, "what would Thor do"; write known conditions and symptom attach/detach.
- **No beta instance;** shadow mode + CI replays instead.
- **LXC checklist:** 2 cores / 1 GB / 8 GB appPool, unprivileged, nesting+keyctl, DHCP (operator adds the reservation), apt proxy via `/usr/local/bin/apt-proxy-detect.sh` -> CT 135 `10.10.10.55:3142` installed by hand, HA rule `EMERGENCY needed`, NPM `thor.lotusguild.org` with Authelia two_factor group admin and the `/mcp` exemptions, Kuma monitor, Prometheus scrape + Grafana staleness rule, PatchMon agent, deploy from `LotusGuild/thor` via signed Gitea webhook, post-merge check (prod HEAD, services active, `/health` 200, no tracebacks).
## 7. Tests
- **Fixtures in the repo, trimmed:** only the series/lines Thor queries for T1-T4 and the DIMM reboot, as JSON, with usernames and unrelated content scrubbed.
- **Replays:** fake clock, fake Tinker, fake Gandalf API; feed the recorded windows; assert the table above, including that every report Gandalf and hwmonDaemon would have made gets "covered" from `/covering`.
- **CI on every PR in Gitea Actions, modelled on Pulse's `ci.yml`:** lint (ruff/flake8) + no em/en dash check; pytest with coverage; the replays (a changed ticket count fails the PR); bandit + semgrep; pip-audit, licence check, CycloneDX SBOM artifact; integration job with a MariaDB service and fake upstreams (contract tests for `/covering` and the Tinker payload, like Pulse's Gandalf contract tests; MCP token validation against a test JWKS); gitleaks, actionlint, zizmor, shellcheck; `web_template` drift check; Playwright for the UI.
## Follow-up issues and changes
- LotusGuild/tinker_tickets#123: `dedup_key`, key lookup, link API, creator attribution, 7 day reopen window, per-app backfill.
- LotusGuild/gandalf#66: Gandalf's side of the contract (`[gandalf]` tag, machine-key read API for Thor, pre-check `/covering`, `dedup_key`, source-down handoff, takes over hwmonDaemon's network checks).
- LotusGuild/gandalf#67: maintenance fan-out (one Gandalf maintenance also opens a Kuma window and a Grafana silence, each with its own end time).
- LotusGuild/hwmonDaemon#42: hwmonDaemon's side (`[hwmon]` tag, clear notes, pre-check `/covering`, `dedup_key`, per-check switches, migration order).
- hwmonDaemon#39 closed as superseded: memory is Thor's first check.
- Wiki: title standard updated on the Tinker pages; corosync gotcha on the cluster overview fixed (two knet links since 2026-11-18).
- Not done: README update, Thor phase issues, code.
## Verification (for the build)
- The Area 7 CI suite, especially the T1-T4 replays producing exactly the outcomes in the test-case table.
- Each migration's shadow output reviewed by the operator before go-live.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
This is a planning session, to be done before any code. The README has the charter and the boundaries between the three apps.
Questions to settle
node_vmstat_oom_kill, memory and pressure (PSI),upandscrape_duration, Ceph exporter metrics.Reference incident
Tinker 615797777, gandalf#57 and hwmonDaemon#39.
Handoff brief for the planning session (2026-11-25)
This collects what the Gandalf sessions learned that Thor's planning needs. It's here so a fresh session can start from it.
Ownership rule (decided 2026-11-23)
Routing rule for new checks: if node_exporter or Loki exposes it, it's thor; if only the box knows, it's hwmonDaemon; if it's network, it's gandalf.
Data sources (all verified working)
http://10.10.10.48:9090.node_boot_time_seconds,node_vmstat_oom_kill,upandscrape_duration_secondsall work.http://10.10.10.69:3100.{job="journal", host="<host>", unit="<unit>"}, and thehostlabel matches Gandalf's host names.{job="pve-tasks"}, but they're only ingested after a host comes back./readycan return 503 while queries still work.10.10.10.4:9283.ceph_health_status,ceph_health_detail{name,severity}(e.g. OSDMAP_FLAGS, RECENT_CRASH, BLUESTORE_SLOW_OP_ALERT) andceph_osd_flag_*.pauseflags aren't exported, so read them fromceph osd dump.Code thor can lift from gandalf
reboots.py(gandalf#65): the Loki client,find_shutdown, and planned-reboot grace.[host][auto][production][issue][...].Known conditions thor must handle (operator decisions)
noout: set on purpose, long-term, because of compute-storage-02. A "maintenance flag left on" check therefore needs an acknowledge or known-condition mechanism (for example, linked to the tracking ticket), not a fixed time limit.Lessons from real incidents
Operator preferences (apply everywhere)
Open thor issues
Thor plan: decisions from the 2026-11-25 planning session
Context
On 2026-11-23 an OOM loop on compute-storage-01 (CT 154) stalled Ceph cluster-wide. hwmonDaemon on that host saw nothing, and Gandalf opened a false P1 network ticket (Tinker 615797777, fixed in gandalf#57). Thor is the out-of-band host and cluster health app: it owns anything visible from Prometheus, Loki, Proxmox or Ceph, and opens one ticket per root cause. thor#1 asked seven questions; this session answered all of them with the operator, testing every choice against real incidents. No code was written. The follow-up issues and wiki changes are listed at the end.
Test cases (used for every decision)
[compute-storage-01][auto][thor][software] Out of memory: CT 154 ..., P3 ~05:15, P2 ~05:20, P1 06:01. Ceph slow ops, pvestatd and scrape timeouts are "Also seen". 673679581 listed as related. Gandalf: no ticketpausevia Proxmox UI (task 03:12:10, only visible inpve-tasks, ingested ~03:26); switches down ~03:11; clean logind power-off cs-01/cs-02 03:21:35; UPS firmware cut rack power ~03:25-03:32; Prometheus has no samples 03:16-03:38; no Kuma window, no Grafana silenceSince 2026-11-18 corosync has two knet links (10.10.10.x priority 20, 10.10.90.x priority 10), which is the fix for T3/T4.
1. Where Thor runs and who watches it
EMERGENCY needednode-affinity rule (BMC servers: compute-storage-01:1, compute-storage-02:2, storage-01:2). The operator accepted the risk after seeing the strictinvestigation-toolsrule (never cs-01/cs-02, holds Kuma, Grafana, Prometheus, Tinker, Loki). Real independence comes with 3+ racks later.thor./health(503 when the monitor loop is stale, like Gandalf'shealth()inapp.py); Prometheus scrapes a Thor heartbeat metric with a Grafana staleness rule.node_vmstat_oom_kill,node_boot_time_seconds, Loki lines).pausewas set during the switch outage and cleared before Thor was back).2. Ticket contract (gandalf, hwmonDaemon, thor)
dedup_key, formatscope:subject:kind, e.g.host:compute-storage-01:oom,cluster:ceph:BLUESTORE_SLOW_OP_ALERT,site:rack1:power). Only the owner writes the description; others comment.GET /api/incidents/covering?host=X(orscope=). Covered: comment on Thor's ticket. Thor down or slow: open as normal (fail open). The same call reports known conditions.relates_tolink; operator closes.[source][auto][app][area] Summary [scope][environment][type]with[gandalf],[hwmon],[thor]. Checked againsthelpers/TicketHash.php: the tag and Gandalf's tag reorder change no existing hash.noout-> 693930698; the old UPS battery (two Grafana silences until 2029).pause,nut_ups_on_battery, UniFi firmware events and logind lines are backup signals.3. Data sources and cadence
node_vmstat_oom_kill, PSInode_pressure_*,node_memory_*,up,scrape_duration_seconds,ceph_health_detail,ceph_mon_quorum_status,ceph_osd_{up,in},ceph_osd_flag_*,ceph_pg_*,nut_*.transport="kernel", givesglobal_oom,cpuset,task_memcg=/lxc/<id>), logind shutdown, corosync link/quorum, watchdog, andpve-tasks(use the UPID start time, not ingest time). A failed query retries, never "nothing found".thor@pve(PVEAuditor), tried across nodes:/cluster/ceph/flags(includespause),/cluster/ceph/status,/cluster/ha/status/current,/cluster/status(node names and IPs), guests and storage.micro1,large1); match Prometheus by IP (cs-02's job is stilllargeoneexporter).4. Root-cause grouping
node_pressure_cpu_waiting_seconds_totalsustained for an hour, P4.5. Migration from hwmonDaemon
pct dfvia Pulse every 15 min; the Sia hostd rule (CT 141) becomes a per-volume exception in Thor.6. Stack and deployment
thor.service(Flask/gunicorn: UI, API, MCP) +thor-monitor.service;web_templateterminal look; one "Needs attention" list.reboots.py(Loki client,find_shutdown),TicketClient,ticket_textinto Thor, crediting the source commit; shared package later./covering, known conditions, memory, MCP v1) + thor#4 reboots; 2 Ceph migration + thor#3 view; 3 thor#2 drive registry (needs hwmonDaemon#41); then LXC storage and CPU.https://thor.lotusguild.org/mcp, Authelia clientthor-mcp,two_factor, scopesthor:read/thor:write, per the wiki checklist; callback port 47826 or 47827, whichever the Gandalf MCP session doesn't take): read incidents, timeline, blind periods, maintenance, known conditions, "what would Thor do"; write known conditions and symptom attach/detach./usr/local/bin/apt-proxy-detect.sh-> CT 13510.10.10.55:3142installed by hand, HA ruleEMERGENCY needed, NPMthor.lotusguild.orgwith Authelia two_factor group admin and the/mcpexemptions, Kuma monitor, Prometheus scrape + Grafana staleness rule, PatchMon agent, deploy fromLotusGuild/thorvia signed Gitea webhook, post-merge check (prod HEAD, services active,/health200, no tracebacks).7. Tests
/covering.ci.yml: lint (ruff/flake8) + no em/en dash check; pytest with coverage; the replays (a changed ticket count fails the PR); bandit + semgrep; pip-audit, licence check, CycloneDX SBOM artifact; integration job with a MariaDB service and fake upstreams (contract tests for/coveringand the Tinker payload, like Pulse's Gandalf contract tests; MCP token validation against a test JWKS); gitleaks, actionlint, zizmor, shellcheck;web_templatedrift check; Playwright for the UI.Follow-up issues and changes
dedup_key, key lookup, link API, creator attribution, 7 day reopen window, per-app backfill.[gandalf]tag, machine-key read API for Thor, pre-check/covering,dedup_key, source-down handoff, takes over hwmonDaemon's network checks).[hwmon]tag, clear notes, pre-check/covering,dedup_key, per-check switches, migration order).Verification (for the build)