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 1 commit
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
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