# Thor's side of the ticket contract How Gandalf and hwmonDaemon ask Thor whether something is already covered, before they open a host-, cluster- or source-level ticket. The contract itself is in the plan on [thor#1](https://code.lotusguild.org/LotusGuild/thor/issues/1); the callers' side is gandalf#66 and hwmonDaemon#42. ## The rules in short - Each app tickets only its own evidence domain. The root cause owns the ticket, whichever app found it; symptoms are "Also seen" comments. Thor is the only correlator. - Before opening a host-, cluster- or source-level ticket, ask Thor. If Thor says **covered**, comment on the ticket it names instead. If Thor doesn't answer, answers an error, or is slow (use a short timeout, 3 to 5 s), **open your ticket as normal**. Fail open: never lose a ticket. - Nobody closes tickets automatically. ## Request ``` GET http://10.10.10.86/api/incidents/covering?host= GET http://10.10.10.86/api/incidents/covering?scope=cluster GET http://10.10.10.86/api/incidents/covering?scope=source:prometheus Authorization: Bearer ``` - Call the CT directly (10.10.10.86), not `thor.lotusguild.org`, which is behind Authelia. - `host` accepts current names and old ones (`large1`, `micro1`). - Keys: give Thor's operator the SHA-256 of your key. It goes in `/etc/thor/thor.json`: `"api_keys": [{"name": "gandalf", "sha256": "", "scopes": ["read"], "sources": ["10.10.10.61/32"]}]`. A wrong or unknown key is a 401, even with identity headers. Only `GET` is allowed. ## Response ```json { "covered": true, "ticket_id": "987654321", "host": "compute-storage-02", "scope": null, "incidents": [ {"key": "cluster:corosync:partition", "kind": "partition", "subject": "cluster", "state": "open", "priority": 1, "summary": "Cluster partition: ...", "mode": "live", "ticket_id": "987654321", "first_seen": 1793825481.9, "last_seen": 1793825662.0, "url": "https://thor.lotusguild.org/incident/cluster:corosync:partition"} ], "known_conditions": [ {"kind": "reboot", "subject": "compute-storage-02", "ticket_id": "693930698", "reason": "compute-storage-02 reboots every 2 to 3 days from a failing DIMM ..."} ] } ``` - **`covered`** is true only when there is a ticket you can comment on: an incident with a live ticket, or a known condition with a tracking ticket. **`ticket_id`** is that ticket. - While a Thor check runs in **shadow** (all of phase 1), its incidents are listed with `"mode": "shadow"` and `"ticket_id": null`, and they do **not** make `covered` true: there is nothing in Tinker to comment on, so open your own ticket. Logging the shadow incident's key next to your ticket helps the comparison before Thor goes live. - Timeline-only incidents (planned maintenance from Gandalf) never appear here. - Times are unix seconds (UTC). - Errors: `400` (no `host` or `scope`), `401` (key), `503` (Thor can't read its database). Treat every error as "not covered". ## What counts as covering what | Ask | Matches | |---|---| | `host=X` | active incidents about X, and active cluster-wide incidents | | `scope=cluster` | active cluster-wide incidents, and incidents on hosts that run Ceph OSDs | | `scope=source:prometheus` | an active "monitoring source down" incident for that source | ## Incident keys (`dedup_key` in Tinker, tinker_tickets#123) `scope:subject:kind`, chosen by the app that owns the ticket. Thor's: | Key | Meaning | |---|---| | `host::oom` | host out of memory (global OOM kills) | | `host::reboot` | unexpected reboot (thor#4) | | `host::fenced` | host lost its cluster link and was fenced | | `cluster:corosync:partition` | two or more nodes fenced or out of quorum | | `cluster:reboots:` | several hosts rebooted together with nothing else explaining it | | `maintenance:gandalf:` | a Gandalf maintenance (timeline only, never a ticket) |