Probes log locally only while the hub is unreachable; the hub confirms silences with that log

Probe: no access log, nothing written while reports get through. When the hub
can't be reached, failed reports go to data/outage.jsonl and unsent results to
data/backlog.jsonl (survives restarts). The first report that gets through
uploads both and they are deleted.

Hub: a probe that misses reports gets a "Not reporting" incident. When it
reports again, the runs from its outage log become confirmed "Hub unreachable"
incidents; the rest of the silence (probe off or restarting) is dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
neil 2026-11-04 20:50:30 -08:00
parent 462525b1e2
commit be727949c1
13 changed files with 449 additions and 32 deletions

View file

@ -13,7 +13,7 @@ from fastapi import APIRouter, FastAPI, HTTPException, Request
from fastapi.responses import FileResponse, JSONResponse, PlainTextResponse, Response
from fastapi.staticfiles import StaticFiles
from app.hub import adguard, db, dns, health, probes, settings
from app.hub import adguard, db, dns, health, outages, probes, settings
from app.version import VERSION
log = logging.getLogger("hub")
@ -34,11 +34,24 @@ async def _retention_loop() -> None:
await asyncio.sleep(3600)
async def _silence_loop() -> None:
"""Open a "not reporting" incident for probes that went quiet."""
while True:
try:
def run():
with db.db() as con:
return outages.open_silences(con)
await asyncio.to_thread(run)
except Exception:
log.exception("silence check failed")
await asyncio.sleep(15)
@contextlib.asynccontextmanager
async def lifespan(_app: FastAPI):
# Startup work happens here, not at import: `update` imports app.main as a check.
db.init()
tasks = [asyncio.create_task(_retention_loop())]
tasks = [asyncio.create_task(_retention_loop()), asyncio.create_task(_silence_loop())]
if settings.get().adguard_configured:
tasks.append(asyncio.create_task(dns.discovery_loop()))
try: