Writer systemd oneshots run as www-data but deploy never chowned writer-pipeline/var, causing EACCES on aggregated-items.json when the store was created by root. Mirror BIT-743 bridge/config/writers fix; rebuild writer-pipeline on webhook when that tree changes. Paperclip-Issue: BIT-25140 Co-authored-by: Cursor <[email protected]>
8.9 KiB
News platform — incident response (aggregator, lag, escalation) — BIT-3915
Operational incident guide for the news-platform stack (Astro SSR, Fastify bridge, headless WordPress, optional writer-pipeline aggregator). Default deployment context: LXC CT 222 (news-project-test, 10.10.50.204, VLAN 1050) — confirm VMID/IP against the current inventory in the paperclip meta-repo (docs/environments/03-lxc.md).
How this runbook fits
| Topic | Canonical doc |
|---|---|
| HTTP health checks, systemd units, Ntfy alerts, first response on service down | NEWS_PLATFORM_MONITORING_ALERTS_BIT746.md and ../monitoring.md |
Aggregator API, store paths, bridge AGGREGATOR_URL |
../AGGREGATOR_OPERATIONS.md |
| Ingest, shortlist, metrics file | ../WRITER_PIPELINE_ANDEBOL.md |
| Deploy order and NPM | ../deployment.md |
Use this document when the site is partially healthy (localhost checks pass) but editorial pipeline signals are wrong: stale aggregator data, missing candidates, or lag between real-world news and what writers see.
1. Severity quick matrix
| Symptom | User impact | Typical owner | First doc |
|---|---|---|---|
| Customer URL returns 5xx/timeout while CT checks pass | High — public outage | DevOps + edge (NPM/TLS/DNS) | BIT-746 runbook § public_page |
| Bridge / frontend / WordPress / Redis failing on CT | High | DevOps | docs/monitoring.md + BIT-746 |
| Aggregator up but no new items for a site; writers only see WordPress | Medium — pipeline degradation | DevOps or on-call engineer | §2 below |
| Lag — items exist but ingestedAt is old vs breaking news | Medium | Same + editorial triage | §3 below |
2. Aggregator stall — detection and recovery
2.1 What “stalled” means
The aggregator HTTP process (default :3310) answers /health, but at least one of these is true:
GET /statsshows flat counts for the affectedsiteover multiple hours while sources are known to publish.GET /shortlist?site=…&limit=10returns no or only very old items (compareingestedAt/publishedAtin JSON to wall clock).- Bridge
GET /writers/:id/candidatesresponses showcandidate_sourcedominated bywordpresswhereaggregatorormixedwas expected (requiresAGGREGATOR_URLset on the bridge — seeAGGREGATOR_OPERATIONS.md).
2.2 Detection (on the LXC or dev host)
Replace host/port if your deployment overrides AGGREGATOR_HOST / AGGREGATOR_PORT.
# Liveness + resolved store path
curl -fsS "http://127.0.0.1:3310/health" | jq .
# Totals and per-site counts (repeat twice, ~5 min apart, while news is expected)
curl -fsS "http://127.0.0.1:3310/stats" | jq .
# Newest shortlist for the site (inspect timestamps)
curl -fsS "http://127.0.0.1:3310/shortlist?site=andebol.net&limit=15" | jq '.[:3] | .[] | {title, publishedAt, ingestedAt}'
# Optional: compare bridge candidates mix (needs auth context on your env)
# curl -fsS "http://127.0.0.1:3200/writers/<agentId>/candidates" | jq '{candidate_source, aggregator_total_items}'
Also inspect ingest logs: if ingest runs only from cron/systemd, check the last successful run time vs schedule in AGGREGATOR_OPERATIONS.md § Suggested scheduling.
2.3 Common causes
| Cause | Clues | Recovery |
|---|---|---|
| Aggregator process not running | /health connection refused |
Start the supervised process (npm run aggregator after npm run build in writer-pipeline/, or your systemd/PM2 unit if installed). |
| Stale process, memory wedge | /health OK but /stats frozen; high RSS |
Restart aggregator process; re-run §2.2. |
| Ingest not executed | Store file old mtime; /stats unchanged |
POST /ingest?site=<site> (see AGGREGATOR_OPERATIONS.md); fix cron/timer if missing. |
| Bad or blocked RSS upstream | Errors in ingest logs; one feed down | Per-feed isolation — see WRITER_PIPELINE_ANDEBOL.md § Fallback behaviour; adjust *.sources.json (maxItems, URL). |
| Bridge not wired to aggregator | Candidates never show aggregator |
Set AGGREGATOR_URL on bridge; restart news-bridge; verify with bridge health/deep check. |
2.4 Recovery checklist (ordered)
- Confirm which site (
andebol.net, etc.) and config file (writer-pipeline/config/<site>.sources.json). curl§2.2 — capture before snapshots (for the incident thread).- Restart aggregator if the process is wedged; verify
/healthagain. - Run
POST /ingest?site=…once; re-check/statsand/shortlist. - If still flat, open
writer-pipeline/var/metrics.jsonltail forerrorsfrom the last cycle (see pipeline doc). - If bridge integration suspected,
curlbridge/health?checks=true(Redis/WordPress path). - Post evidence (commands + short JSON excerpts) in the Paperclip issue before closing.
3. Lag monitoring and alerts
3.1 Definitions
- Ingest lag: difference between latest
publishedAtamong shortlisted items and wall clock, or between consecutive successfulPOST /ingestcompletions (whichever you can measure from logs). - Writer lag: time from item entering the shortlist to editorial action — operational, not only technical.
3.2 Signals already available
| Signal | Where |
|---|---|
Per-cycle token estimates and metrics.errors |
writer-pipeline/var/metrics.jsonl (WRITER_PIPELINE_ANDEBOL.md) |
| Aggregator freshness | /shortlist, /search?…&max_age_hours=, /stats |
| Stack latency / dependency health | Bridge GET /health?checks=true (../monitoring.md) |
| Scheduled health and Ntfy | news-healthcheck.timer + /etc/news-platform/healthcheck.env |
3.3 Alerting (MVP vs future)
- Today: BIT-746-style checks prove process up and HTTP paths; they do not assert “RSS fresh within N minutes.” For lag-specific paging, either extend
deploy/scripts/healthcheck.shwith a small aggregator freshness probe (curl/statsor/shortlistand compare timestamps to thresholds) or add a dedicated systemd timer that runs a script in-repo (prefer committing the script underdeploy/scripts/with documentation here). - When adding probes: keep timeouts aligned with
docs/monitoring.md(avoid hammering external RSS from tight timers).
4. Incident escalation
4.1 Technical ladder (news-platform)
Align with BIT-746 escalation: DevOps first on CT222, CTO for architecture / blast radius, CEO for customer-visible sustained outage or security suspicion.
Add for aggregator / writer-pipeline:
| Situation | Action |
|---|---|
| Single failed ingest; self-heals on retry | Log in issue; no escalation. |
| Repeated ingest errors or copyright/licensing uncertainty | Pause automated ingest for the suspect feed; involve editorial + CTO. |
Data corruption suspicion on aggregated-items.json |
Stop aggregator; take a file backup; restore from known good or re-ingest; involve CTO before destructive deletes. |
EACCES on writer-pipeline/var/aggregated-items.json (systemd User=www-data) |
var/ or the JSON store was created as root (manual run, deploy gap). On CT222: sudo mkdir -p /opt/news-platform/writer-pipeline/var && sudo chown -R www-data:www-data /opt/news-platform/writer-pipeline/var; re-run news-writer-andebol.service / news-writer-newsproject.service. Deploy scripts enforce ownership on every pull (BIT-25140). |
4.2 Paperclip and queue hygiene
- Operational work (deploy, timers, secrets) should leave evidence in the linked issue (commands,
journalctlexcerpts, commit SHA). - If a run was stuck in
queuedwith an emptystartedAtfor extended time, automation mayreleasethe lock per BIT-517 §3a — the assignee cancheckoutagain when ready; do not treat the pulse comment alone as a rollback of technical state.
5. Acceptance mapping (BIT-3915)
| Requirement | Section |
|---|---|
| Aggregator stall detection and recovery | §2 |
| Lag monitoring and alerts (signals + MVP vs extensions) | §3 |
| Incident escalation procedures | §4 |