Skip to content

feat: add HTTP health endpoints to instance manager - #12

Merged
usiegj00 merged 2 commits into
mainfrom
feature/health-endpoints
Jan 25, 2026
Merged

feat: add HTTP health endpoints to instance manager#12
usiegj00 merged 2 commits into
mainfrom
feature/health-endpoints

Conversation

@usiegj00

Copy link
Copy Markdown
Collaborator

Summary

Adds HTTP health endpoints to the instance manager, following the CNPG pattern. These endpoints provide health information without spawning processes, enabling future replacement of the current redis-cli based probes.

Fixes #6

Endpoints

Endpoint Purpose Returns 200 when Returns 503 when
/healthz Liveness Redis responds to PING Redis not responding
/readyz Readiness Redis ready for traffic Loading, syncing, master link down
/status Debugging Always Never

Features

  • No process spawning: Uses persistent Redis connection
  • Cached status: Refreshes every 1 second to minimize Redis load
  • Readiness intelligence: Checks loading state, sync progress, master link status
  • Configurable: --health-port flag (default 8080)

Response Examples

/healthz

{"status":"ok","redis_pid":123,"uptime_seconds":3600}

/readyz

{"status":"ok","role":"master","connected_clients":5,"loading":false}

/status

{
  "redis": {"pid":123,"role":"master","connected_clients":5,...},
  "replication": {"role":"master","connected_slaves":2,...},
  "instance_manager": {"version":"v1.7.0","uptime_seconds":3600,...}
}

Test Coverage

  • Unit tests for all endpoints and helper functions
  • E2E tests validating:
    • /healthz returns 200 when healthy
    • /readyz returns 200 when ready
    • /status returns detailed info
    • /healthz returns 503 when Redis is killed
    • Recovery after restart

Test Plan

  • Unit tests pass
  • E2E tests pass
  • /healthz returns 200 for healthy Redis
  • /healthz returns 503 when Redis killed
  • /readyz returns 200 for ready Redis
  • /status returns comprehensive info

Add /healthz, /readyz, and /status HTTP endpoints to the instance manager
following the CNPG pattern. These endpoints provide health information
without spawning processes.

Endpoints:
- GET /healthz - Liveness check (200 if Redis responds to PING)
- GET /readyz - Readiness check (200 if Redis is ready for traffic)
- GET /status - Detailed status for debugging/monitoring

Features:
- Persistent Redis connection (no process spawning)
- Cached health status (refreshed every 1s)
- Readiness checks for loading, syncing, master link status
- Configurable port via --health-port flag

Includes:
- Unit tests for all endpoints
- E2E tests validating endpoint behavior

Fixes #6
@usiegj00
usiegj00 merged commit 4c76491 into main Jan 25, 2026
12 checks passed
@usiegj00
usiegj00 deleted the feature/health-endpoints branch January 25, 2026 04:32
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.

Add HTTP health endpoints to instance manager

1 participant