deislabs / hippo

The WebAssembly Platform

Home Page:https://docs.hippofactory.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use status codes in health checks

lann opened this issue · comments

commented

It is conventional for an HTTP health check endpoint to reflect its status in both text (e.g. "healthy"/"unhealthy") and status code (200 / 503 is common). Some tools like Nomad's HTTP health checks expect status codes to reflect service health.

If anyone wants to take a crack at this...

Here's where we register health checks:

hippo/src/Web/Program.cs

Lines 30 to 33 in 8fee82b

builder.Services.AddHealthChecks()
.AddDbContextCheck<ApplicationDbContext>()
.AddCheck<BindleHealthCheck>("Bindle")
.AddCheck<NomadHealthCheck>("Nomad");

Here's where we map those health checks to /healthz:

endpoints.MapHealthChecks("/healthz");

Here's the code for said health checks: https://github.com/deislabs/hippo/tree/8fee82bfb819534a21546b79aa934deeb9eed3bd/src/Infrastructure/HealthChecks

The best place to start may be to read through Health checks in ASP.NET Core. I skimmed the document when spiking it out - it's possible we can accomplish smarter health checks using the existing system. If not, I'm not opposed to replacing it with a custom health check controller.