Go-live prep: link API, adopt shadow incidents, comments stay on Thor's ticket #12

Merged
jared merged 2 commits from go-live-prep into main 2026-11-27 10:36:16 -05:00
Owner

tinker_tickets#123 is on prod (#124, released in #125). This PR fixes what Thor still needed before any check leaves shadow. No UI change. Every check stays in shadow until the operator flips one in /etc/thor/thor.json.

Checked against Tinker prod

  • Create replies: create() already reads every reply from #124: created, deduplicated, updated, reopened, recurrence_noted, new_recurrence. Each one returns the ticket_id the incident now lives on. A new test covers each reply.
  • Keys: every key Thor emits matches Tinker's format (A-Za-z0-9_.:-, case sensitive), including cluster:ceph_alert:<CODE>.
  • Write access: from CT 173, a GET to https://t.lotusguild.org/api/ticket_link_api.php with Thor's key returned 405, not 403 and not an Authelia redirect. That means the NPM exemption is in place and the key has read_write scope.

Changes

  1. Bug fix: comments followed an attached ticket.
    • incident_ticket() returned the newest action row with a ticket number. attach (and now link) rows record another app's ticket.
    • So after attach_ticket, Thor's "Also seen" and "Cleared" comments would have gone to that ticket.
    • It now reads only Thor's own creates (open, escalate, refresh). Tested against the fake store and against MariaDB.
  2. Link API. TinkerClient.link() posts to api/ticket_link_api.php.
    • A 409 (already linked) or a 404 (ticket gone) counts as done, so a retry after a lost reply never loops.
    • A 401 or 403 turns writes off, the same as create and comment do.
    • New link outbox action: it waits until both tickets exist, then links "other relates_to Thor's".
    • It is queued by attach_ticket, and by root-cause absorption when the lower incident was live and so has a ticket of its own.
    • This is the "Root cause comment + relates_to link" from the thor#1 contract.
  3. Adopting an open shadow incident at go-live.
    • If a check goes live while one of its incidents is open in shadow, that incident never had an open sent.
    • Before this fix, every later comment would have waited for a ticket that didn't exist, until it gave up after 30 attempts.
    • Now the incident sends its open on the first live cycle, then carries on as normal.

Tests

  • Local: ruff is clean, and 147 passed, 7 skipped. The skipped ones are the MariaDB tests, which the integration job runs.
  • New tests:
    • The link client's status handling.
    • Every contract reply from create.
    • Comments staying on Thor's ticket after an attach.
    • A link waiting for both tickets.
    • A live root cause linking the lower ticket it explains.
    • A shadow incident adopted at go-live.
    • MariaDB incident_ticket ignoring an attach row.

🤖 Generated with Claude Code

tinker_tickets#123 is on prod (#124, released in #125). This PR fixes what Thor still needed before any check leaves shadow. No UI change. Every check stays in shadow until the operator flips one in `/etc/thor/thor.json`. ## Checked against Tinker prod - **Create replies:** `create()` already reads every reply from #124: `created`, `deduplicated`, `updated`, `reopened`, `recurrence_noted`, `new_recurrence`. Each one returns the `ticket_id` the incident now lives on. A new test covers each reply. - **Keys:** every key Thor emits matches Tinker's format (`A-Za-z0-9_.:-`, case sensitive), including `cluster:ceph_alert:<CODE>`. - **Write access:** from CT 173, a GET to `https://t.lotusguild.org/api/ticket_link_api.php` with Thor's key returned **405**, not 403 and not an Authelia redirect. That means the NPM exemption is in place and the key has `read_write` scope. ## Changes 1. **Bug fix: comments followed an attached ticket.** - `incident_ticket()` returned the newest action row with a ticket number. `attach` (and now `link`) rows record *another app's* ticket. - So after `attach_ticket`, Thor's "Also seen" and "Cleared" comments would have gone to that ticket. - It now reads only Thor's own creates (`open`, `escalate`, `refresh`). Tested against the fake store and against MariaDB. 2. **Link API.** `TinkerClient.link()` posts to `api/ticket_link_api.php`. - A 409 (already linked) or a 404 (ticket gone) counts as done, so a retry after a lost reply never loops. - A 401 or 403 turns writes off, the same as `create` and `comment` do. - New `link` outbox action: it waits until both tickets exist, then links "other `relates_to` Thor's". - It is queued by `attach_ticket`, and by root-cause absorption when the lower incident was live and so has a ticket of its own. - This is the "Root cause comment + relates_to link" from the thor#1 contract. 3. **Adopting an open shadow incident at go-live.** - If a check goes live while one of its incidents is open in shadow, that incident never had an `open` sent. - Before this fix, every later comment would have waited for a ticket that didn't exist, until it gave up after 30 attempts. - Now the incident sends its `open` on the first live cycle, then carries on as normal. ## Tests - Local: ruff is clean, and 147 passed, 7 skipped. The skipped ones are the MariaDB tests, which the integration job runs. - New tests: - The link client's status handling. - Every contract reply from `create`. - Comments staying on Thor's ticket after an attach. - A link waiting for both tickets. - A live root cause linking the lower ticket it explains. - A shadow incident adopted at go-live. - MariaDB `incident_ticket` ignoring an attach row. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
jared added 1 commit 2026-11-27 10:24:37 -05:00
Go-live prep: link API, adopt shadow incidents, comments stay on Thor's ticket
CI / Lint (flake8, house style) (pull_request) Failing after 1m29s
CI / Test (pytest) (pull_request) Successful in 1m31s
CI / Security (bandit, pip-audit) (pull_request) Successful in 1m5s
CI / Integration (MariaDB) (pull_request) Successful in 1m48s
CI / Scan (secrets, workflows, shell, patterns) (pull_request) Successful in 1m46s
CI / UI (screenshots) (pull_request) Successful in 2m37s
CI / Deploy (pull_request) Skipped
1f8c702ef3
tinker_tickets#123 is on prod. Before any check goes live:

- incident_ticket() only reads Thor's own creates. attach and link rows record
  another app's ticket number, and after an attach every later comment would
  have gone to that ticket.
- TinkerClient.link() calls api/ticket_link_api.php (409 and 404 count as done).
  attach_ticket and a live root-cause absorption now queue a relates_to link
  beside their comment, as the thor#1 contract says.
- An incident open in shadow when its check goes live gets its open then,
  instead of comments waiting forever for a ticket that was never created.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
jared added 1 commit 2026-11-27 10:35:10 -05:00
Tests: flake8 continuation indent
CI / Lint (flake8, house style) (pull_request) Successful in 46s
CI / Test (pytest) (pull_request) Successful in 47s
CI / Security (bandit, pip-audit) (pull_request) Successful in 1m6s
CI / Integration (MariaDB) (pull_request) Successful in 1m58s
CI / Scan (secrets, workflows, shell, patterns) (pull_request) Successful in 1m39s
CI / UI (screenshots) (pull_request) Successful in 2m54s
CI / Deploy (pull_request) Skipped
e0491cba31
Co-Authored-By: Claude Opus 5.5 <[email protected]>
jared scheduled this pull request to auto merge when all checks succeed 2026-11-27 10:36:14 -05:00
jared merged commit bd1241dd62 into main 2026-11-27 10:36:16 -05:00
jared deleted branch go-live-prep 2026-11-27 10:36:17 -05:00
Author
Owner

Merged and deployed. Note: Gitea merged as soon as I asked, without waiting for the PR checks, because they aren't required checks. Both runs then finished green: PR run 4069 and main run 4070.

Post-merge check on CT 173:

  • prod HEAD bd1241d.
  • thor and thor-monitor active, /health 200.
  • No tracebacks.
  • The only ERROR line is gunicorn 27's "Control server error: Read-only file system /var/lib/thor/.gunicorn". It has been logged on every start since 2026-11-26 and is harmless; a small follow-up will silence it.

Memory is live (operator's choice, 2026-11-27): /etc/thor/thor.json checks.memory = "live", with a backup at thor.json.bak-20261127. thor-monitor restarted cleanly. reboots, cluster, ceph_alerts, scrapes, pvestatd and maintenance stay in shadow:

  • Reboots and fencing wait for Gandalf's /covering pre-check, to avoid duplicate host-down tickets.
  • Ceph waits for phase 2.

There are no active incidents, so nothing has been sent yet. The 7-day reopen is tinker_tickets#126.

Merged and deployed. Note: Gitea merged as soon as I asked, without waiting for the PR checks, because they aren't required checks. Both runs then finished green: PR run 4069 and main run 4070. Post-merge check on CT 173: - prod HEAD bd1241d. - `thor` and `thor-monitor` active, `/health` 200. - No tracebacks. - The only ERROR line is gunicorn 27's "Control server error: Read-only file system /var/lib/thor/.gunicorn". It has been logged on every start since 2026-11-26 and is harmless; a small follow-up will silence it. **Memory is live** (operator's choice, 2026-11-27): `/etc/thor/thor.json` `checks.memory = "live"`, with a backup at `thor.json.bak-20261127`. `thor-monitor` restarted cleanly. `reboots`, `cluster`, `ceph_alerts`, `scrapes`, `pvestatd` and `maintenance` stay in shadow: - Reboots and fencing wait for Gandalf's `/covering` pre-check, to avoid duplicate host-down tickets. - Ceph waits for phase 2. There are no active incidents, so nothing has been sent yet. The 7-day reopen is tinker_tickets#126.
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#12