Health checks
A health check tells OpenPanel when a replica of a service is ready for traffic. The OpenPanel agent on each server runs it against the replica's container, from the server itself, so the port it checks does not need to be public and the image needs no tool such as curl.
What it decides
- During a deploy, the new replicas start beside the old ones. The old ones stop only once every new replica is ready, so a version that never becomes healthy never takes over. A service with a volume is the exception: its old replica stops first. See The single-instance rule.
- The deployment counts as running when every replica's container runs and is healthy.
- OpenPanel's edge sends requests and connections only to replicas that are ready, on every server.
The two kinds
| Kind | Healthy when |
|---|---|
| HTTP | A GET to the path on that port answers with a status from 200 to 399. A redirect counts as an answer and is not followed. The request carries User-Agent: openpanel-agent-health. |
| TCP | A connection to that port opens. |
The port must be one of the service's ports: an HTTP check needs an http port, a TCP check an http or tcp port.
Timing
| Setting | Default | Range |
|---|---|---|
intervalSeconds, time between checks | 10 | 2 to 300 |
timeoutSeconds, how long one check may take | 5 | 1 to 60 |
retries, failed checks in a row before the replica is unhealthy | 3 | 1 to 10 |
A replica is starting until its first check passes, healthy after a check passes, and unhealthy after retries failed checks in a row. One passing check makes it healthy again. An unhealthy replica is not restarted; it gets traffic again once it passes a check.
Set one
Open the project and click the service on the canvas. In the Health check card of its Settings tab, choose HTTP or TCP, its Port, and for HTTP the Path. Interval, Timeout and Retries are optional. Click Save, then deploy.
Like every setting, a health check takes effect at the next deploy.
Without a health check
A replica counts as ready as soon as its container runs. If its image declares its own Docker HEALTHCHECK, the replica is ready once Docker reports it healthy.
A container that runs is not always one that answers: without a check, traffic can reach a new replica before the app inside it listens. Set a check on every service that serves traffic.
When a deploy does not become healthy
While a new replica fails its check, the old replicas go on serving. OpenPanel marks the deployment failed when:
- its image cannot be pulled, or its container cannot be made;
- the server refuses the change;
- its container exits three times;
- or it is still not ready 15 minutes after the rollout began. The deployment's error then says why, for example "Not ready after 15 minutes: it failed its health check."
The service then goes back to the deployment that ran before. See Deploy.