Phase 1, PR 2: engine, memory check, symptoms, outbox, and the 11-23 replay #6

Merged
jared merged 1 commits from engine into main 2026-11-25 23:07:12 -05:00
Owner

Second phase 1 PR from the plan on #1. Thor now finds things: host OOM is its first check, and it groups symptoms under the cause. Everything runs in shadow: actions are recorded and never sent (no check goes live before tinker_tickets#123).

The 11-23 replay (T1), on real data

tests/fixtures/t1.json was recorded read-only from the real Prometheus and Loki (scripts/record_fixture.py t1). It's replayed through the real monitor, engine and checks every 120 s from 05:00 to 06:40.

Time (UTC) What Thor does
05:14 Opens one ticket, P1: [compute-storage-01][auto][thor][software] Out of memory: CT 154 pelican-wings-02 java OOM-killed 1 time [single-node][production][issue]. "Why this priority": pvestatd timed out on storage-01, monitor-01 and monitor-02 at 05:11:03, with the first kill at 05:11:08.
05:22, 05:26, 05:50 "Also seen" comments: scrape timeouts on other hosts, pvestatd everywhere, Ceph OSD_SLOW_PING_TIME_* and DB_DEVICE_STALLED_READ_ALERT.
05:44, 06:14 Refreshes the ticket text (same dedup_key, so Tinker updates it in place), at most every 30 min.
~06:00 Loki's recorded 500s hold the window. Thor retries; nothing is lost.
06:18 Final refresh ("OOM-killed 11 times"), then the Cleared note, 15 min after the last kill.

No other incident opens anywhere, and all 11 kills are attributed to CT 154. One deliberate change from the thor#1 table: that table guessed P3 rising to P1 at 06:01. On real data the cluster stalled with the first kill (pvestatd timeouts are zero on normal days), so under our agreed rule it opens at P1. You confirmed this.

What's new

  • Engine (thor/engine.py): one incident per root cause, keyed by the dedup_key.
    • New causes are held one cycle, so symptoms from the same moment land in the first text.
    • Symptoms attach to the highest active cause they relate to: the same host, or any host for cluster-wide symptoms when the cause can stall the cluster (a host with OSDs).
    • Unexplained symptoms stay in Thor and never become tickets.
    • Priority only rises. Cleared after 15 min quiet, as a note only. A cleared cause coming back starts a new round with the same key.
    • Each check owns the summary and priority of its incidents.
  • Memory check (thor/checks/memory.py):
    • node_vmstat_oom_kill plus the kernel oom-kill: and Killed process lines: global vs cgroup, victim, CT and its name (from Proxmox), the cpuset that triggered it, anon/shmem RSS.
    • Kills whose lines never reached Loki still count.
    • A container hitting its own limit is a note, never a ticket.
    • Includes the "What to check" list from Tinker 615797777.
  • Symptom checks (thor/checks/symptoms.py): slow or failed node_exporter scrapes, pvestatd timeouts, and Ceph health alerts that switch on. Standing alerts like BLUESTORE_SLOW_OP_ALERT are ignored.
  • NeedsSource: a check whose source is blind keeps the window for review later. It's never read as "nothing happened".
  • Outbox (thor/outbox.py): live actions go to Tinker with backoff (comments wait for their ticket); shadow actions are only recorded.
  • Host registry (thor/hosts.py): Prometheus mapped by IP, Loki through aliases (micro1, large1), node renames picked up from the Proxmox API.
  • Migration 2: incidents, actions (outbox), observations.
  • Bug fixed (found by recording against the real Prometheus): re.escape produced \. inside PromQL and LogQL strings, which Prometheus rejects with a 400. The new query_regex() doubles the backslashes.

Verification

  • 89 unit tests plus 5 MariaDB tests pass; coverage is 97% with the DB.
  • flake8, bandit and shellcheck are clean. No em or en dashes.
  • After merge: verify the deploy, then watch a few live cycles in shadow on CT 173.

Next

PR 3 adds reboots (#4), corosync and fencing, maintenance from Gandalf, and known conditions, with the T2, T3, T4 and DIMM-reboot replays.

🤖 Generated with Claude Code

Second phase 1 PR from the plan on #1. Thor now finds things: host OOM is its first check, and it groups symptoms under the cause. **Everything runs in shadow**: actions are recorded and never sent (no check goes live before tinker_tickets#123). ## The 11-23 replay (T1), on real data `tests/fixtures/t1.json` was recorded read-only from the real Prometheus and Loki (`scripts/record_fixture.py t1`). It's replayed through the real monitor, engine and checks every 120 s from 05:00 to 06:40. | Time (UTC) | What Thor does | |---|---| | 05:14 | **Opens one ticket**, P1: `[compute-storage-01][auto][thor][software] Out of memory: CT 154 pelican-wings-02 java OOM-killed 1 time [single-node][production][issue]`. "Why this priority": pvestatd timed out on storage-01, monitor-01 and monitor-02 at 05:11:03, with the first kill at 05:11:08. | | 05:22, 05:26, 05:50 | "Also seen" comments: scrape timeouts on other hosts, pvestatd everywhere, Ceph `OSD_SLOW_PING_TIME_*` and `DB_DEVICE_STALLED_READ_ALERT`. | | 05:44, 06:14 | Refreshes the ticket text (same `dedup_key`, so Tinker updates it in place), at most every 30 min. | | ~06:00 | Loki's recorded 500s hold the window. Thor retries; nothing is lost. | | 06:18 | Final refresh ("OOM-killed 11 times"), then the **Cleared** note, 15 min after the last kill. | No other incident opens anywhere, and all 11 kills are attributed to CT 154. **One deliberate change from the thor#1 table:** that table guessed P3 rising to P1 at 06:01. On real data the cluster stalled with the first kill (pvestatd timeouts are zero on normal days), so under our agreed rule it opens at P1. You confirmed this. ## What's new - **Engine** (`thor/engine.py`): one incident per root cause, keyed by the `dedup_key`. - New causes are held one cycle, so symptoms from the same moment land in the first text. - Symptoms attach to the highest active cause they relate to: the same host, or any host for cluster-wide symptoms when the cause can stall the cluster (a host with OSDs). - Unexplained symptoms stay in Thor and never become tickets. - Priority only rises. Cleared after 15 min quiet, as a note only. A cleared cause coming back starts a new round with the same key. - Each check owns the summary and priority of its incidents. - **Memory check** (`thor/checks/memory.py`): - `node_vmstat_oom_kill` plus the kernel `oom-kill:` and `Killed process` lines: global vs cgroup, victim, CT and its name (from Proxmox), the cpuset that triggered it, anon/shmem RSS. - Kills whose lines never reached Loki still count. - A container hitting its own limit is a note, never a ticket. - Includes the "What to check" list from Tinker 615797777. - **Symptom checks** (`thor/checks/symptoms.py`): slow or failed node_exporter scrapes, pvestatd timeouts, and Ceph health alerts that switch on. Standing alerts like `BLUESTORE_SLOW_OP_ALERT` are ignored. - **`NeedsSource`:** a check whose source is blind keeps the window for review later. It's never read as "nothing happened". - **Outbox** (`thor/outbox.py`): live actions go to Tinker with backoff (comments wait for their ticket); shadow actions are only recorded. - **Host registry** (`thor/hosts.py`): Prometheus mapped by IP, Loki through aliases (`micro1`, `large1`), node renames picked up from the Proxmox API. - **Migration 2:** `incidents`, `actions` (outbox), `observations`. - **Bug fixed** (found by recording against the real Prometheus): `re.escape` produced `\.` inside PromQL and LogQL strings, which Prometheus rejects with a 400. The new `query_regex()` doubles the backslashes. ## Verification - 89 unit tests plus 5 MariaDB tests pass; coverage is 97% with the DB. - flake8, bandit and shellcheck are clean. No em or en dashes. - After merge: verify the deploy, then watch a few live cycles in shadow on CT 173. ## Next PR 3 adds reboots (#4), corosync and fencing, maintenance from Gandalf, and known conditions, with the T2, T3, T4 and DIMM-reboot replays. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
jared added 1 commit 2026-11-25 23:02:30 -05:00
Engine, memory check, symptom checks, outbox, T1 replay
CI / Lint (flake8, house style) (pull_request) Successful in 50s
CI / Test (pytest) (pull_request) Successful in 52s
CI / Security (bandit, pip-audit) (pull_request) Successful in 1m1s
CI / Integration (MariaDB) (pull_request) Successful in 1m40s
CI / Scan (secrets, workflows, shell, patterns) (pull_request) Successful in 1m15s
CI / Deploy (pull_request) Skipped
983ba27386
- thor/engine.py: one incident per root cause. New causes held one cycle, symptoms attached
  to the highest cause they relate to (same host, or cluster-wide effects for causes that
  can stall the cluster), priority only rises, rate-limited refresh, cleared after 15 min.
- thor/checks/memory.py: node_vmstat_oom_kill + kernel oom-kill lines; global vs cgroup,
  victim and CT, trigger cpuset; P3 / P2 (loop) / P1 (Ceph or other hosts stalling).
- thor/checks/symptoms.py: scrape timeouts, pvestatd timeouts, Ceph alerts switching on.
- thor/outbox.py: live actions to Tinker with backoff; shadow actions are only recorded.
- Migration 2: incidents, actions, observations.
- PromQL/LogQL regex escaping fixed (found by recording against the real Prometheus).
- tests/replay.py + tests/fixtures/t1.json: 2026-11-23 replayed through the real monitor:
  exactly one ticket (P1 from the start: pvestatd timed out on three other hosts with the
  first kill), 15 symptoms as Also seen, cleared 06:18, Loki's 06:00 outage delays only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jared merged commit fa9a4b0f78 into main 2026-11-25 23:07:12 -05:00
Author
Owner

Merged and deployed through CI.

Deploy verified on CT 173:

  • Prod HEAD: fa9a4b0f789b5f06483600df0ff746c6f7a5391c.
  • thor and thor-monitor are active; /health returns 200 with that sha.
  • Migration 2 applied on start (Applied schema migration 2). The monitor came up with 4 checks and resumed from the stored window (first cycle covered 100 s, not a fresh 120 s).
  • Every cycle so far is "ok"; no incidents or observations on a quiet night (expected); no tracebacks in journalctl -u thor -u thor-monitor.
Merged and deployed through CI. **Deploy verified on CT 173:** - Prod HEAD: `fa9a4b0f789b5f06483600df0ff746c6f7a5391c`. - `thor` and `thor-monitor` are active; `/health` returns 200 with that sha. - Migration 2 applied on start (`Applied schema migration 2`). The monitor came up with 4 checks and resumed from the stored window (first cycle covered 100 s, not a fresh 120 s). - Every cycle so far is "ok"; no incidents or observations on a quiet night (expected); no tracebacks in `journalctl -u thor -u thor-monitor`.
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: LotusGuild/thor#6