mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
hotfix(healthcheck): properly calculate healthy status (#7746)
This commit is contained in:
9
coderd/apidoc/docs.go
generated
9
coderd/apidoc/docs.go
generated
@ -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"
|
||||
}
|
||||
|
9
coderd/apidoc/swagger.json
generated
9
coderd/apidoc/swagger.json
generated
@ -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"
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user