Skip to content

Feat/historic health status#110

Open
vtnphan wants to merge 3 commits into
devfrom
feat/historic--health-status
Open

Feat/historic health status#110
vtnphan wants to merge 3 commits into
devfrom
feat/historic--health-status

Conversation

@vtnphan

@vtnphan vtnphan commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Pull Request

Summary

Adds historical downtime tracking for the components on the admin System Status dashboard (Seqera API, compute env, Tower Agent), so admins can see how often and for how long each has been degraded/unhealthy over time — without storing a row for every poll.

Changes

  • New SystemStatusIncident model / system_status_incidents table (migration a6ee1af2c156): one row per downtime period per component (started_at, ended_at null while ongoing, status, message). Only degraded/unhealthy periods are recorded — healthy checks write nothing, so storage scales with actual outages, not polling frequency.
  • app/services/health.py: _update_incidents runs on every real probe refresh (inside refresh_db_cache) and opens/closes/splits incident rows on status transitions (recovers to healthy → close; still down at same severity → leave open, refresh message; severity changes e.g. degraded → unhealthy → close and open a new one). Added get_incidents (window/component query), _summarize_downtime (incident count, downtime seconds, uptime % — clipped to the query window), and to_downtime_dict.
  • app/schemas/health.py: ComponentIncident, ComponentDowntimeSummary, ComponentDowntime, SystemStatusDowntimeResponse.
  • app/routes/system_status.py: new GET /admin/api/system-status/history?hours=&component= (admin-gated, same as the existing /admin/api/system-status), returns per-component incidents + downtime summary for the requested window (max 30 days).
  • app/templates/admin/system_status.html: new "History" card with a 24h/7d/30d window switch — an all-green bar per component with colored segments only where it was actually down (positioned by real incident start/end), a short list of recent incidents (start/end-or-"ongoing"/duration/message), and per-component uptime %.
  • Tests: incident open/close/split transitions, window/component filtering, downtime-clipping math, and the new endpoint's auth/shape (tests/test_services_health.py, tests/test_routes_admin_system_status.py).

How to Test

  1. uv sync --all-extras
  2. uv run alembic upgrade head (creates system_status_incidents)
  3. uv run pytest tests/test_services_health.py tests/test_routes_admin_system_status.py -v
  4. uv run pytest tests/ -v
  5. Manually: run the backend, open /admin/system-status. To see an incident recorded, temporarily break a probe (e.g. an invalid SEQERA_ACCESS_TOKEN), let a refresh run, then restore it — the History card should show one incident with a start and end time.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • Added tests
  • Updated docs
  • Linted and tested locally
  • Follows project style guidelines

@vtnphan
vtnphan marked this pull request as ready for review July 24, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant