diff --git a/coderd/apidoc/docs.go b/coderd/apidoc/docs.go index 4b261e947034a..08ef7df926c76 100644 --- a/coderd/apidoc/docs.go +++ b/coderd/apidoc/docs.go @@ -10322,13 +10322,13 @@ const docTemplate = `{ "healthy": { "type": "boolean" }, - "healthzResponse": { + "healthz_response": { "type": "string" }, "reachable": { "type": "boolean" }, - "statusCode": { + "status_code": { "type": "integer" } } @@ -10440,7 +10440,7 @@ const docTemplate = `{ "derp": { "$ref": "#/definitions/healthcheck.DERPReport" }, - "pass": { + "healthy": { "description": "Healthy is true if the report returns no errors.", "type": "boolean" }, @@ -10457,6 +10457,9 @@ const docTemplate = `{ "type": "object", "properties": { "error": {}, + "healthy": { + "type": "boolean" + }, "response": { "$ref": "#/definitions/healthcheck.WebsocketResponse" } diff --git a/coderd/apidoc/swagger.json b/coderd/apidoc/swagger.json index 49abc0824d326..1437f446d94d6 100644 --- a/coderd/apidoc/swagger.json +++ b/coderd/apidoc/swagger.json @@ -9307,13 +9307,13 @@ "healthy": { "type": "boolean" }, - "healthzResponse": { + "healthz_response": { "type": "string" }, "reachable": { "type": "boolean" }, - "statusCode": { + "status_code": { "type": "integer" } } @@ -9425,7 +9425,7 @@ "derp": { "$ref": "#/definitions/healthcheck.DERPReport" }, - "pass": { + "healthy": { "description": "Healthy is true if the report returns no errors.", "type": "boolean" }, @@ -9442,6 +9442,9 @@ "type": "object", "properties": { "error": {}, + "healthy": { + "type": "boolean" + }, "response": { "$ref": "#/definitions/healthcheck.WebsocketResponse" } diff --git a/coderd/healthcheck/accessurl.go b/coderd/healthcheck/accessurl.go index f8babac89595c..c773c5560eb64 100644 --- a/coderd/healthcheck/accessurl.go +++ b/coderd/healthcheck/accessurl.go @@ -11,11 +11,11 @@ import ( ) type AccessURLReport struct { - Healthy bool - Reachable bool - StatusCode int - HealthzResponse string - Error error + Healthy bool `json:"healthy"` + Reachable bool `json:"reachable"` + StatusCode int `json:"status_code"` + HealthzResponse string `json:"healthz_response"` + Error error `json:"error"` } type AccessURLOptions struct { diff --git a/coderd/healthcheck/healthcheck.go b/coderd/healthcheck/healthcheck.go index cc5def5719c1d..101fe18613570 100644 --- a/coderd/healthcheck/healthcheck.go +++ b/coderd/healthcheck/healthcheck.go @@ -15,7 +15,7 @@ type Report struct { // Time is the time the report was generated at. Time time.Time `json:"time"` // Healthy is true if the report returns no errors. - Healthy bool `json:"pass"` + Healthy bool `json:"healthy"` DERP DERPReport `json:"derp"` AccessURL AccessURLReport `json:"access_url"` @@ -80,6 +80,8 @@ func Run(ctx context.Context, opts *ReportOptions) (*Report, error) { wg.Wait() report.Time = time.Now() - report.Healthy = report.DERP.Healthy + report.Healthy = report.DERP.Healthy && + report.AccessURL.Healthy && + report.Websocket.Healthy return &report, nil } diff --git a/coderd/healthcheck/websocket.go b/coderd/healthcheck/websocket.go index cbab40e054e79..e69d6339ff19b 100644 --- a/coderd/healthcheck/websocket.go +++ b/coderd/healthcheck/websocket.go @@ -21,6 +21,7 @@ type WebsocketReportOptions struct { } type WebsocketReport struct { + Healthy bool `json:"healthy"` Response WebsocketResponse `json:"response"` Error error `json:"error"` } @@ -96,6 +97,7 @@ func (r *WebsocketReport) Run(ctx context.Context, opts *WebsocketReportOptions) } c.Close(websocket.StatusGoingAway, "goodbye") + r.Healthy = true } type WebsocketEchoServer struct { diff --git a/docs/api/debug.md b/docs/api/debug.md index d425cb4a5dd13..0f9a33d993f55 100644 --- a/docs/api/debug.md +++ b/docs/api/debug.md @@ -42,9 +42,9 @@ curl -X GET http://coder-server:8080/api/v2/debug/health \ "access_url": { "error": null, "healthy": true, - "healthzResponse": "string", + "healthz_response": "string", "reachable": true, - "statusCode": 0 + "status_code": 0 }, "derp": { "error": null, @@ -206,10 +206,11 @@ curl -X GET http://coder-server:8080/api/v2/debug/health \ } } }, - "pass": true, + "healthy": true, "time": "string", "websocket": { "error": null, + "healthy": true, "response": { "body": "string", "code": 0 diff --git a/docs/api/schemas.md b/docs/api/schemas.md index 88447cc9aec8b..39c4e55907270 100644 --- a/docs/api/schemas.md +++ b/docs/api/schemas.md @@ -5867,21 +5867,21 @@ Parameter represents a set value for the scope. { "error": null, "healthy": true, - "healthzResponse": "string", + "healthz_response": "string", "reachable": true, - "statusCode": 0 + "status_code": 0 } ``` ### Properties -| Name | Type | Required | Restrictions | Description | -| ----------------- | ------- | -------- | ------------ | ----------- | -| `error` | any | false | | | -| `healthy` | boolean | false | | | -| `healthzResponse` | string | false | | | -| `reachable` | boolean | false | | | -| `statusCode` | integer | false | | | +| Name | Type | Required | Restrictions | Description | +| ------------------ | ------- | -------- | ------------ | ----------- | +| `error` | any | false | | | +| `healthy` | boolean | false | | | +| `healthz_response` | string | false | | | +| `reachable` | boolean | false | | | +| `status_code` | integer | false | | | ## healthcheck.DERPNodeReport @@ -6212,9 +6212,9 @@ Parameter represents a set value for the scope. "access_url": { "error": null, "healthy": true, - "healthzResponse": "string", + "healthz_response": "string", "reachable": true, - "statusCode": 0 + "status_code": 0 }, "derp": { "error": null, @@ -6376,10 +6376,11 @@ Parameter represents a set value for the scope. } } }, - "pass": true, + "healthy": true, "time": "string", "websocket": { "error": null, + "healthy": true, "response": { "body": "string", "code": 0 @@ -6394,7 +6395,7 @@ Parameter represents a set value for the scope. | ------------ | ---------------------------------------------------------- | -------- | ------------ | ------------------------------------------------ | | `access_url` | [healthcheck.AccessURLReport](#healthcheckaccessurlreport) | false | | | | `derp` | [healthcheck.DERPReport](#healthcheckderpreport) | false | | | -| `pass` | boolean | false | | Healthy is true if the report returns no errors. | +| `healthy` | boolean | false | | Healthy is true if the report returns no errors. | | `time` | string | false | | Time is the time the report was generated at. | | `websocket` | [healthcheck.WebsocketReport](#healthcheckwebsocketreport) | false | | | @@ -6403,6 +6404,7 @@ Parameter represents a set value for the scope. ```json { "error": null, + "healthy": true, "response": { "body": "string", "code": 0 @@ -6415,6 +6417,7 @@ Parameter represents a set value for the scope. | Name | Type | Required | Restrictions | Description | | ---------- | -------------------------------------------------------------- | -------- | ------------ | ----------- | | `error` | any | false | | | +| `healthy` | boolean | false | | | | `response` | [healthcheck.WebsocketResponse](#healthcheckwebsocketresponse) | false | | | ## healthcheck.WebsocketResponse