Add Command Health Check Endpoints#101
Add Command Health Check Endpoints#101Yash Shrivastava (alephys26) wants to merge 7 commits intomainfrom
Conversation
Wiz Scan Summary
To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension. |
There was a problem hiding this comment.
Pull request overview
Adds command-level health check support to Heimdall to improve observability and enable deployment workflows (e.g., blue/green with test endpoints).
Changes:
- Introduces new HTTP endpoints
/command/healthand/command/{id}/health. - Adds opt-in
health_checkflag on commands and aplugin.HealthCheckerextension point. - Implements core health check orchestration (pair resolution, parallel probing, aggregation) and updates local config example.
Reviewed changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/plugin/plugin.go | Adds HealthChecker interface for plugin-provided health probes. |
| pkg/object/command/command.go | Adds HealthCheck opt-in flag to command definition. |
| internal/pkg/heimdall/heimdall.go | Registers the new health check HTTP routes. |
| internal/pkg/heimdall/health.go | Implements health check resolution, probing, and response shaping. |
| configs/local.yaml | Enables health_check: true for the local ping command example. |
| internal/pkg/object/command/postgres/postgres.go | gofmt-only change to Cleanup signature formatting. |
| internal/pkg/object/command/clickhouse/column_types.go | gofmt-only formatting adjustments. |
| internal/pkg/janitor/janitor.go | gofmt-only alignment/formatting changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| var err error | ||
| if hc, ok := pair.handler.(plugin.HealthChecker); ok { | ||
| err = hc.HealthCheck(ctx, pair.cluster) | ||
| } else { | ||
| err = h.pluginProbe(ctx, pair.cluster, pair.handler) | ||
| } |
There was a problem hiding this comment.
The fallback path for handlers that don’t implement plugin.HealthChecker calls handler.Execute(...) as a probe. This is risky because Execute may be stateful/side-effecting and may assume a fully-populated job.Job (some built-in commands call j.Context.Unmarshal(...) without a nil check, which would panic here). Safer options are to require HealthChecker for commands that opt into health checks, or make the fallback return a clear "health check not implemented" error instead of executing the command.
Background
We did not have health checks for the commands in Heimdall. Introducing per command and all command health check endpoints for greater observability and to allow features such as AWS's blue-green deployment with configurable test endpoint to shift production traffic.
Changes
Health Check API and Logic:
/command/healthand/command/{id}/healthto report health status for all commands or a specific command, respectively, including detailed per-command and per-cluster results. [1] [2]internal/pkg/heimdall/health.go, including parallel health probing, result aggregation, and error reporting.Command and Plugin Structure Updates:
HealthCheckboolean field to theCommandstruct to allow commands to opt in or out of health checks.HealthCheckerinterface in the plugin system, enabling plugins to provide custom health check logic.Configuration and Miscellaneous:
configs/local.yamlto sethealth_check: truefor the test ping command, demonstrating the new feature.go fmtformatting changes.Tests
Tested on
pingcommand on local.Test 1:
/command/healthTest 2:
/command/{id}/health