commit | fc0e3062d07dc60c1faef9d33108b9781e890297 | [log] [tgz] |
---|---|---|
author | Antonio Barone <syntonyze@gmail.com> | Wed Oct 21 13:17:48 2020 +0200 |
committer | Luca Milanesio <luca.milanesio@gmail.com> | Fri Oct 23 20:04:03 2020 +0000 |
tree | 74a828655ff00c669935f92cf47e1d59a3effa7b | |
parent | f857d921267908a9e3d8f43390335eff9798e4b9 [diff] |
Normalize response payload returned by replicas Change [1] introduced the ability for replicas to expose a healthcheck endpoint, however it introduced a bug whereby the response payload was wrapped with the http status and its value, rather than the value itself. The following payload was returned: ``` { "status_code": 200, "value": { "elapsed": 82, "auth": {...}, "querychanges": {...}, "jgit": {...}, ... } } ``` rather than: ``` { "elapsed": 82, "auth": {...}, "querychanges": {...}, "jgit": {...}, ... } ``` Make replicas return the same payload response as the non-replicas. Bug: Issue 13550 [1] I6ab4524dcaa96d8571c3fad2eb03624f00902943 Change-Id: Ia741d7fedc23a29299046cb5224d36d0b36c7d70
Allow having a single entry point to check the availability of the services that Gerrit exposes.
Clone or link this plugin to the plugins directory of Gerrit‘s source tree, and then run bazel build on the plugin’s directory.
Example:
git clone --recursive https://gerrit.googlesource.com/gerrit git clone https://gerrit.googlesource.com/plugins/healthcheck pushd gerrit/plugins && ln -s ../../healthcheck . && popd cd gerrit && bazel build plugins/healthcheck
The output plugin jar is created in:
bazel-genfiles/plugins/healthcheck/healthcheck.jar
Copy the healthcheck.jar into the Gerrit's /plugins directory and wait for the plugin to be automatically loaded. The healthcheck plugin is compatible with both Gerrit master and slave setups. The only difference to bear in mind is that some checks may not be successful on slaves (e.g. query changes) because the associated subsystem is switched off.
The healthcheck plugin exposes a single endpoint under its root URL and provides a JSON output of the Gerrit health status.
The HTTP status code returned indicates whether Gerrit is healthy (HTTP status 200) or has some issues (HTTP status 500).
The HTTP response payload is a JSON output that contains the details of the checks performed.
Each check returns a JSON payload with the following information:
ts: epoch timestamp in millis of the individual check
elapsed: elapsed time in millis to complete the check
result: result of the health check
Example of a healthy Gerrit response:
GET /config/server/healthcheck~status 200 OK Content-Type: application/json )]}' { "ts": 139402910202, "elapsed": 100, "querychanges": { "ts": 139402910202, "elapsed": 20, "result": "passed" }, "reviewdb": { "ts": 139402910202, "elapsed": 50, "result": "passed" }, "projectslist": { "ts": 139402910202, "elapsed": 100, "result": "passed" }, "jgit": { "ts": 139402910202, "elapsed": 80, "result": "passed" } }
Example of a Gerrit instance with the projects list timing out:
GET /config/server/healthcheck~status 500 ERROR Content-Type: application/json )]}' { "ts": 139402910202, "elapsed": 100, "querychanges": { "ts": 139402910202, "elapsed": 20, "result": "passed" }, "reviewdb": { "ts": 139402910202, "elapsed": 50, "result": "passed" }, "projectslist": { "ts": 139402910202, "elapsed": 100, "result": "timeout" }, "jgit": { "ts": 139402910202, "elapsed": 80, "result": "passed" } }
As for all other endpoints in Gerrit, some metrics are automatically emitted when the /config/server/healthcheck~status
endpoint is hit (thanks to the Dropwizard library).
Some additional metrics are also produced to give extra insights on their result about results and latency of healthcheck sub component, such as jgit, reviewdb, etc.
More information can be found in the config.md file.