Skip to content

hotfix(healthcheck): properly calculate healthy status #7746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions coderd/healthcheck/accessurl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions coderd/healthcheck/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions coderd/healthcheck/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type WebsocketReportOptions struct {
}

type WebsocketReport struct {
Healthy bool `json:"healthy"`
Response WebsocketResponse `json:"response"`
Error error `json:"error"`
}
Expand Down Expand Up @@ -96,6 +97,7 @@ func (r *WebsocketReport) Run(ctx context.Context, opts *WebsocketReportOptions)
}

c.Close(websocket.StatusGoingAway, "goodbye")
r.Healthy = true
}

type WebsocketEchoServer struct {
Expand Down
7 changes: 4 additions & 3 deletions docs/api/debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
29 changes: 16 additions & 13 deletions docs/api/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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 | | |

Expand All @@ -6403,6 +6404,7 @@ Parameter represents a set value for the scope.
```json
{
"error": null,
"healthy": true,
"response": {
"body": "string",
"code": 0
Expand All @@ -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
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy