Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Infrastructure API

Canonical reference: docs/api-reference.md (generated endpoint directory) — this page is a task-oriented summary.

Administrative endpoints for service status, maintenance mode, and hot-path cache invalidation. Mounted at the catch-all router {"/api/v1/infra/[...]", sol_http_infra, []}, which dispatches internally on the trailing path segments and HTTP method.

The infra API is deliberately small. It exposes only status, maintenance, and cache operations — not config read/reload, version, or log-level changes. (Those were removed/never implemented; do not document or call them.)

Authentication

GET /api/v1/infra/status and GET /api/v1/infra/maintenance are on the Auth-exempt list so orchestrators and LB tooling can read them without credentials — but non-admin callers get a trimmed status body (see below). GET /api/v1/infra/cache-affinity requires a valid token but not admin. All mutating endpoints (POST/DELETE) require the admin role — i.e. permissions containing the literal "*" (the middleware additionally gates POST /api/v1/infra/ on infra:manage). When authentication is disabled (auth_enabled = false) the admin gate is bypassed.

When the admin check fails a mutating endpoint returns 403 with the Zerg envelope {"ok":false,"error":{"code":"insufficient_permissions","message":"admin required"}}. Unknown path/method combinations return 405 with the envelope {"ok":false,"error":{"code":"method not allowed","message":"method not allowed"}}.

Endpoints

Service Status

GET /api/v1/infra/status

Aggregated operational status: server health, version, uptime, maintenance flag, per-subsystem service probes, cluster info, and atom table usage. This is the detailed counterpart to the auth-exempt /api/v1/ready — it includes the per-subsystem reason/detail maps that /ready strips.

Response (200 — admin view; non-admins receive the trimmed booleans only):

{
  "status": "ok",
  "version": "1.003.0",
  "uptime_ms": 7200000,
  "maintenance": { "enabled": false },
  "services": {
    "mnesia":       { "status": "ok",    "tables": 35 },
    "zmq":          { "status": "ok",    "sockets": 3 },
    "postgres":     { "status": "ok" },
    "ets":          { "status": "ok",    "tables": 14 },
    "forgejo":      { "status": "ok",    "code": 200 },
    "crow_ci":      { "status": "ok",    "code": 200 },
    "prometheus":   { "status": "ok",    "code": 200 },
    "tempo":        { "status": "error", "reason": "connection_refused" },
    "grafana":      { "status": "ok",    "code": 200 },
    "models":       { "status": "ok",    "ready": 2 },
    "workers":      { "status": "ok",    "stale": 0 }
  },
  "cluster": {
    "nodes": 1,
    "node_names": ["sol@blue"]
  },
  "atoms": {
    "count": 41832,
    "limit": 1048576
  },
  "tenancy": {
    "mode": "single_org",
    "tenant_unit": "sol",
    "worker_tenancy": "single_tenant",
    "shared_worker_supported": false,
    "shared_worker_allowed": false
  }
}
FieldDescription
statusok, degraded, or unknown — aggregated from sol_health:check_all/0.
versionApplication vsn (application:get_key(sol, vsn)); falls back to "0.10.0" if unset.
uptime_msBEAM wall-clock uptime in ms.
tenancyThe shipped posture: single_org per Sol, single_tenant per worker, no shared-worker multi-tenant claim. See Tenancy posture.
maintenanceCurrent maintenance-mode status map (see below).
servicesPer-subsystem + infra-service probes. Health-check entries mirror the subsystems in /api/v1/ready but with details retained. Infra probes (forgejo, crow_ci, prometheus, tempo, grafana, postgres) are live HTTP/PG probes.
cluster{nodes, node_names} from `[node
atomsAtom-table count vs. limit.

The infra service probes are best-effort and timeout-bounded (2 s connect, 3 s response). A failing probe is reported as {"status":"error","reason":"timeout" | "connection_refused" | "<atom>"}, Not as an HTTP error — the endpoint itself always returns 200.

Non-admin (anonymous) trim: because the route is auth-exempt, anyone can read it — so callers without the "*" permission receive only the overall status plus services reduced to health booleans ({"mnesia": true, "zmq": false, …}). Version, uptime, maintenance state, cluster node names, atom counts, and grafana internals are admin-only:

{
  "status": "degraded",
  "services": { "mnesia": true, "zmq": false, "postgres": true }
}

Maintenance Mode — Status

GET /api/v1/infra/maintenance

Returns the current maintenance-mode status plus the count of in-flight shutdown operations.

Response (200):

{
  "enabled": false,
  "reason": null,
  "enabled_at": null,
  "in_flight": 0
}
FieldDescription
enabledWhether maintenance mode is active.
reasonFree-text reason recorded when maintenance was enabled (admin-supplied or "manual").
enabled_atms timestamp when maintenance was enabled, or null.
in_flightCount of in-flight shutdown operations from sol_shutdown:in_flight/0. Best-effort: failures default to 0.

Maintenance Mode — Enable

POST /api/v1/infra/maintenance/enable

Enter maintenance mode. Admin-only. Request body is optional.

Request Body (optional):

{ "reason": "rolling deploy 0.549" }

If the body is missing or not JSON, reason defaults to "manual".

Response (200):

{
  "ok": true,
  "maintenance": { "enabled": true, "reason": "rolling deploy 0.549", "enabled_at": 1716192000000 },
  "in_flight": 2
}

Maintenance Mode — Disable

POST /api/v1/infra/maintenance/disable

Exit maintenance mode. Admin-only. No request body.

Response (200):

{
  "ok": true,
  "maintenance": { "enabled": false, "reason": null, "enabled_at": null }
}

Cache Invalidation

POST /api/v1/infra/cache-invalidate

Invalidate hot-path configuration caches held in persistent_term (auth_exempt_paths, rate_limit_enabled, provider health cache, etc.). Admin-only. Call this after changing auth/rate-limit config that is cached on the hot path.

The actor (sol_identity:get_uuid/0) is recorded in the audit log as config_cache_invalidate on target "infra/cache".

Response (200):

{
  "ok": true,
  "invalidated": ["exempt_paths", "rate_limit_enabled"]
}

The invalidated list is the fixed set of cache keys flipped by sol_auth_middleware:invalidate_cache/0 — it does not echo the request body. The older cache_keys / detail fields documented elsewhere are not produced by the current handler.

Cache Affinity — Stats

GET /api/v1/infra/cache-affinity

Return current cache-affinity statistics (sol_cache_affinity:stats/0). Requires a valid token with the infra:read permission; no admin required.

Response (200):

{
  "entries": {
    "worker_a": { "model": "glm-5.1", "last_used_ms": 1716192000000 },
    "worker_b": { "model": "glm-5.1", "last_used_ms": 1716192001000 }
  }
}

When the cache is empty or the call throws, the response is {"entries":{}}.

Cache Affinity — Clear

DELETE /api/v1/infra/cache-affinity

Clear all cache-affinity entries (wildcard invalidate). Admin-only.

Response (200):

{ "ok": true }

Error Summary

CodeBodyCondition
403{"ok":false,"error":{"code":"insufficient_permissions","message":"admin required"}}Mutating endpoint called without "*" permission.
405{"ok":false,"error":{"code":"method not allowed","message":"method not allowed"}}Path/method combination not routed.

The status and probe endpoints (GET /infra/status, GET /infra/maintenance, GET /infra/cache-affinity) always return 200 with the collected state — individual subsystem failures appear inside the JSON body, not as HTTP errors.

Examples

# Read detailed service status (with per-subsystem reasons)
curl -H "Authorization: Bearer $TOKEN" \
  http://localhost:21434/api/v1/infra/status

# Enter maintenance mode with a reason
curl -X POST http://localhost:21434/api/v1/infra/maintenance/enable \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"reason":"rolling deploy 0.549"}'

# Invalidate hot-path config caches after a config change
curl -X POST http://localhost:21434/api/v1/infra/cache-invalidate \
  -H "Authorization: Bearer $TOKEN"

Health — auth-exempt liveness (/api/v1/health) and readiness (/api/v1/ready) probes. /ready runs the same subsystem checks as /infra/status but strips details and returns 503 when degraded.