chore: make health checks gooder-er#21
Conversation
|
|
||
| FROM mcr.microsoft.com/dotnet/aspnet:8.0-noble-chiseled AS runtime | ||
| FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime | ||
| RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* |
64cc781 to
03f033f
Compare
| echo "Waiting for all services to be healthy..." | ||
| # Wait for services with health checks to be healthy (4 services) and all services to be up | ||
| timeout 300 bash -c 'until [ $(docker compose ps --format "{{.Health}}" | grep -c "healthy") -ge 4 ] && [ $(docker compose ps --format "{{.Status}}" | grep -c "Up") -ge 5 ]; do sleep 5; done' | ||
| # Wait for services with health checks to be healthy (7 services) and all services to be up |
There was a problem hiding this comment.
This is useful when it struggles starting and I am only moderately ashamed to reveal I let claude code rip on this script.
There was a problem hiding this comment.
If we drop the curl thing; i'd just make this check that nothing has failed and pause for like 2 minutes before hitting URLs.
There was a problem hiding this comment.
Yeah I like that approach. It's not a 'proper' test of the services is it anyway? Just making sure everything starts up correctly in docker compose right?
There was a problem hiding this comment.
It's not a proper test suite, but it does hit and validate API calls.
i'm thinking coarse-grained "hit these APIs and expect some data back" sort of stuff, where "these APIs" are things that do some integration-y stuff - e.g. hitting DBs, hitting kafka, etc. This serves to validate local dev works, and is a smoke test for deeper issues.
| KAFKA__SCHEMAREGISTRY: "http://redpanda:8082" | ||
| KAFKA__GROUPID: "stickerlandia-user-management" | ||
| healthcheck: | ||
| test: ["CMD", "curl", "-f", "http://localhost:8080/api/users/v1/health"] |
There was a problem hiding this comment.
We've both done different things for health; I don't have strong opinions either way
There was a problem hiding this comment.
@scottgerring as in, I've put the healthcheck on the sub URL and you've got it on the route?
There was a problem hiding this comment.
@jeastham1993 Yeah exactly; I don't much mind. On the one hand having it in the URL is consistent, on the other, we'd probably end up wanting to try and hide it from "regular users" ?
There was a problem hiding this comment.
Yeah, unless we put on a /health/service_name endpoint and block that from a load balancer perspective. So it's kind of 'internal only'.
There was a problem hiding this comment.
@jeastham1993 From a containers POV, it can just be each service exposes /health and the orchestrator can hit that; no need for globally unique. Not sure if this messes with what we've got in store on some of the clouds?
6c01215 to
10309e4
Compare
9004478 to
f672d28
Compare
f672d28 to
0b4ca66
Compare
Fixes the build and health checks so that we can run images on arm64 and x86-64, and get our docker-compose CI test running!