WL#11890: REST endpoint for health of routes
Motivation
Load Balancer, containers, ... have a notion of liveness (process is alive) and readiness (can provide its service) to only expose the service if it is really ready.
In the case of MySQL Router there are three states:
- process is alive
- socket is open can receive packets
- backends are healthy and ready to receive connections
"process is alive" (e.g. kill()) and "socket accepts connections" (connect()) are externally checkable, the information if router knows the backends are healthy is only known to the router itself.
Goal
Solution should work with containers, cloud providers and load-balancers like
- kubernetes
- docker
- oracle cloud
Allow to
- query via a GET request if router has backends available and that group replication nodes are ready to accept connections.
Design Requirement
- DR1
- MUST work with static routing
- DR2
- MUST work with innodb-cluster metadata-cache
Functional Requirements
- FR1
- healthcheck MUST return json object with boolean field isActive set to true if at least one backend of the route is able to handle connections
- FR2
- healthcheck MUST return json object with boolean field isActive set to false if no backends is available to handle connections
Background
Kubernetes, load-Balancers, Oracle Cloud and other cloud providers rely on responses to HTTP requests:
- Reponse-Status: 200
- Response-Body matching a regex
- Response-Headers contain a expected value
docker HEALTHCHECK relies on
- script calls + exitcodes
to determine readiness status and could therefore use 'curl' or 'wget' to query any HTTP interface.
Implementation
- part of the
rest_routing
plugin
Interface spec
/routes/{routeName}/health
GET <base>/routes/{routeName}/health
returns object with { "isActive": true } if a route is able to handle client connections. { "isActive": false } otherwise.
A route is able to handle client connections if
- it has at least one destination