Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 1, 2025

This PR adds dedicated health check endpoints to resolve the issue of using / as a liveness/readiness endpoint, which was triggering GitHub API calls and causing flaky response times in Kubernetes deployments.

Changes Made

New Health Check Endpoints

  • /api/health - General health status endpoint
  • /api/ready - Readiness probe endpoint (application ready to serve traffic)
  • /api/live - Liveness probe endpoint (application is alive and responsive)

Key Features

  • Fast response times (~200ms vs potentially slow GitHub API calls)
  • No authentication required - bypasses GitHub authentication middleware
  • No external API calls - completely self-contained health checks
  • JSON responses with application status, version, uptime, and memory info
  • Standard HTTP status codes (200 for healthy)

Middleware Updates

Modified server/middleware/github.ts to skip authentication for health endpoints while maintaining authentication requirements for all other API endpoints.

Example Response

{
  "status": "alive",
  "timestamp": "2025-07-01T22:12:35.849Z",
  "version": "2.0.4",
  "pid": 1234,
  "uptime": 16.176,
  "memory": {
    "used": 9,
    "total": 11
  }
}

Kubernetes Configuration

livenessProbe:
  httpGet:
    path: /api/live
    port: 80
  initialDelaySeconds: 30
  periodSeconds: 10

readinessProbe:
  httpGet:
    path: /api/ready
    port: 80
  initialDelaySeconds: 5
  periodSeconds: 5

Documentation

Updated both README.md and DEPLOYMENT.md with Kubernetes health check configuration examples and usage instructions.

Testing

  • All endpoints respond consistently with 200 status codes
  • Response times under 210ms
  • No external API dependencies
  • Authentication still required for existing endpoints
  • Build and tests pass successfully

This solution eliminates the flaky behavior caused by GitHub API calls during health checks while maintaining the security and functionality of the existing application.

Fixes #212.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.fontshare.com
    • Triggering command: node (vitest) (dns block)
    • Triggering command: node /home/REDACTED/work/copilot-metrics-viewer/copilot-metrics-viewer/node_modules/.bin/nuxt build (dns block)
  • api.fontsource.org
    • Triggering command: node (vitest) (dns block)
    • Triggering command: node /home/REDACTED/work/copilot-metrics-viewer/copilot-metrics-viewer/node_modules/.bin/nuxt build (dns block)
  • fonts.bunny.net
    • Triggering command: node (vitest) (dns block)
    • Triggering command: node /home/REDACTED/work/copilot-metrics-viewer/copilot-metrics-viewer/node_modules/.bin/nuxt build (dns block)
  • fonts.google.com
    • Triggering command: node (vitest) (dns block)
    • Triggering command: node /home/REDACTED/work/copilot-metrics-viewer/copilot-metrics-viewer/node_modules/.bin/nuxt build (dns block)
  • fonts.googleapis.com
    • Triggering command: node (vitest 1) (dns block)
    • Triggering command: node (vitest 2) (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Liveness & Readiness endpoints Add health check endpoints for Kubernetes liveness and readiness probes Jul 1, 2025
Copilot AI requested a review from karpikpl July 1, 2025 22:15
Copilot finished work on behalf of karpikpl July 1, 2025 22:15
@karpikpl karpikpl marked this pull request as ready for review July 2, 2025 02:21
Copy link
Contributor Author

Copilot AI commented Jul 2, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.fontshare.com
    • Triggering command: node (vitest) (dns block)
  • api.fontsource.org
    • Triggering command: node (vitest) (dns block)
  • fonts.bunny.net
    • Triggering command: node (vitest) (dns block)
  • fonts.google.com
    • Triggering command: node (vitest) (dns block)
  • fonts.googleapis.com
    • Triggering command: node (vitest 2) (dns block)
    • Triggering command: node (vitest 1) (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from karpikpl July 2, 2025 02:24
Copilot finished work on behalf of karpikpl July 2, 2025 02:24
@karpikpl
Copy link
Collaborator

karpikpl commented Jul 7, 2025

@copilot resolve conflicts

Copy link
Contributor Author

Copilot AI commented Jul 7, 2025

@copilot resolve conflicts

Conflicts resolved successfully in commit 6f3ffee. The merge conflicts in server/middleware/github.ts have been addressed by combining both the main branch's non-API route authentication skipping logic with the health check endpoint bypassing logic. All tests are passing and the build is successful.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.fontshare.com
    • Triggering command: node /home/REDACTED/work/copilot-metrics-viewer/copilot-metrics-viewer/node_modules/.bin/nuxt build (dns block)
    • Triggering command: node (vitest) (dns block)
  • api.fontsource.org
    • Triggering command: node /home/REDACTED/work/copilot-metrics-viewer/copilot-metrics-viewer/node_modules/.bin/nuxt build (dns block)
    • Triggering command: node (vitest) (dns block)
  • fonts.bunny.net
    • Triggering command: node /home/REDACTED/work/copilot-metrics-viewer/copilot-metrics-viewer/node_modules/.bin/nuxt build (dns block)
    • Triggering command: node (vitest) (dns block)
  • fonts.google.com
    • Triggering command: node /home/REDACTED/work/copilot-metrics-viewer/copilot-metrics-viewer/node_modules/.bin/nuxt build (dns block)
    • Triggering command: node (vitest) (dns block)
  • fonts.googleapis.com
    • Triggering command: node (vitest 1) (dns block)
    • Triggering command: node (vitest 2) (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of karpikpl July 7, 2025 15:26
@karpikpl karpikpl merged commit e9a93db into main Jul 7, 2025
6 checks passed
@karpikpl karpikpl deleted the copilot/fix-212 branch July 7, 2025 16:13
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.

Liveness & Readiness endpoints

2 participants