Skip to content

Commit 8e5f1f0

Browse files
coadlerammario
authored andcommitted
hotfix(healthcheck): properly calculate healthy status (#7746)
1 parent 1b6e52a commit 8e5f1f0

File tree

7 files changed

+43
-29
lines changed

7 files changed

+43
-29
lines changed

coderd/apidoc/docs.go

+6-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

+6-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/healthcheck/accessurl.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import (
1111
)
1212

1313
type AccessURLReport struct {
14-
Healthy bool
15-
Reachable bool
16-
StatusCode int
17-
HealthzResponse string
18-
Error error
14+
Healthy bool `json:"healthy"`
15+
Reachable bool `json:"reachable"`
16+
StatusCode int `json:"status_code"`
17+
HealthzResponse string `json:"healthz_response"`
18+
Error error `json:"error"`
1919
}
2020

2121
type AccessURLOptions struct {

coderd/healthcheck/healthcheck.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type Report struct {
1515
// Time is the time the report was generated at.
1616
Time time.Time `json:"time"`
1717
// Healthy is true if the report returns no errors.
18-
Healthy bool `json:"pass"`
18+
Healthy bool `json:"healthy"`
1919

2020
DERP DERPReport `json:"derp"`
2121
AccessURL AccessURLReport `json:"access_url"`
@@ -80,6 +80,8 @@ func Run(ctx context.Context, opts *ReportOptions) (*Report, error) {
8080

8181
wg.Wait()
8282
report.Time = time.Now()
83-
report.Healthy = report.DERP.Healthy
83+
report.Healthy = report.DERP.Healthy &&
84+
report.AccessURL.Healthy &&
85+
report.Websocket.Healthy
8486
return &report, nil
8587
}

coderd/healthcheck/websocket.go

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type WebsocketReportOptions struct {
2121
}
2222

2323
type WebsocketReport struct {
24+
Healthy bool `json:"healthy"`
2425
Response WebsocketResponse `json:"response"`
2526
Error error `json:"error"`
2627
}
@@ -96,6 +97,7 @@ func (r *WebsocketReport) Run(ctx context.Context, opts *WebsocketReportOptions)
9697
}
9798

9899
c.Close(websocket.StatusGoingAway, "goodbye")
100+
r.Healthy = true
99101
}
100102

101103
type WebsocketEchoServer struct {

docs/api/debug.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ curl -X GET http://coder-server:8080/api/v2/debug/health \
4242
"access_url": {
4343
"error": null,
4444
"healthy": true,
45-
"healthzResponse": "string",
45+
"healthz_response": "string",
4646
"reachable": true,
47-
"statusCode": 0
47+
"status_code": 0
4848
},
4949
"derp": {
5050
"error": null,
@@ -206,10 +206,11 @@ curl -X GET http://coder-server:8080/api/v2/debug/health \
206206
}
207207
}
208208
},
209-
"pass": true,
209+
"healthy": true,
210210
"time": "string",
211211
"websocket": {
212212
"error": null,
213+
"healthy": true,
213214
"response": {
214215
"body": "string",
215216
"code": 0

docs/api/schemas.md

+16-13
Original file line numberDiff line numberDiff line change
@@ -5867,21 +5867,21 @@ Parameter represents a set value for the scope.
58675867
{
58685868
"error": null,
58695869
"healthy": true,
5870-
"healthzResponse": "string",
5870+
"healthz_response": "string",
58715871
"reachable": true,
5872-
"statusCode": 0
5872+
"status_code": 0
58735873
}
58745874
```
58755875

58765876
### Properties
58775877

5878-
| Name | Type | Required | Restrictions | Description |
5879-
| ----------------- | ------- | -------- | ------------ | ----------- |
5880-
| `error` | any | false | | |
5881-
| `healthy` | boolean | false | | |
5882-
| `healthzResponse` | string | false | | |
5883-
| `reachable` | boolean | false | | |
5884-
| `statusCode` | integer | false | | |
5878+
| Name | Type | Required | Restrictions | Description |
5879+
| ------------------ | ------- | -------- | ------------ | ----------- |
5880+
| `error` | any | false | | |
5881+
| `healthy` | boolean | false | | |
5882+
| `healthz_response` | string | false | | |
5883+
| `reachable` | boolean | false | | |
5884+
| `status_code` | integer | false | | |
58855885

58865886
## healthcheck.DERPNodeReport
58875887

@@ -6212,9 +6212,9 @@ Parameter represents a set value for the scope.
62126212
"access_url": {
62136213
"error": null,
62146214
"healthy": true,
6215-
"healthzResponse": "string",
6215+
"healthz_response": "string",
62166216
"reachable": true,
6217-
"statusCode": 0
6217+
"status_code": 0
62186218
},
62196219
"derp": {
62206220
"error": null,
@@ -6376,10 +6376,11 @@ Parameter represents a set value for the scope.
63766376
}
63776377
}
63786378
},
6379-
"pass": true,
6379+
"healthy": true,
63806380
"time": "string",
63816381
"websocket": {
63826382
"error": null,
6383+
"healthy": true,
63836384
"response": {
63846385
"body": "string",
63856386
"code": 0
@@ -6394,7 +6395,7 @@ Parameter represents a set value for the scope.
63946395
| ------------ | ---------------------------------------------------------- | -------- | ------------ | ------------------------------------------------ |
63956396
| `access_url` | [healthcheck.AccessURLReport](#healthcheckaccessurlreport) | false | | |
63966397
| `derp` | [healthcheck.DERPReport](#healthcheckderpreport) | false | | |
6397-
| `pass` | boolean | false | | Healthy is true if the report returns no errors. |
6398+
| `healthy` | boolean | false | | Healthy is true if the report returns no errors. |
63986399
| `time` | string | false | | Time is the time the report was generated at. |
63996400
| `websocket` | [healthcheck.WebsocketReport](#healthcheckwebsocketreport) | false | | |
64006401

@@ -6403,6 +6404,7 @@ Parameter represents a set value for the scope.
64036404
```json
64046405
{
64056406
"error": null,
6407+
"healthy": true,
64066408
"response": {
64076409
"body": "string",
64086410
"code": 0
@@ -6415,6 +6417,7 @@ Parameter represents a set value for the scope.
64156417
| Name | Type | Required | Restrictions | Description |
64166418
| ---------- | -------------------------------------------------------------- | -------- | ------------ | ----------- |
64176419
| `error` | any | false | | |
6420+
| `healthy` | boolean | false | | |
64186421
| `response` | [healthcheck.WebsocketResponse](#healthcheckwebsocketresponse) | false | | |
64196422

64206423
## healthcheck.WebsocketResponse

0 commit comments

Comments
 (0)