Skip to content

feat: include health severity in reports #10817

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 21 commits into from
Nov 23, 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
Prev Previous commit
Next Next commit
WIP
  • Loading branch information
mtojek committed Nov 22, 2023
commit af2d0dc2f50318de50db0dc67ef8f7a8032bb42d
6 changes: 6 additions & 0 deletions coderd/apidoc/docs.go

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

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

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

1 change: 1 addition & 0 deletions coderd/healthcheck/accessurl.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

// @typescript-generate AccessURLReport
type AccessURLReport struct {
// Healthy is left for backward compatibility purposes, use `Severity` instead.
Healthy bool `json:"healthy"`
Severity health.Severity `json:"severity" enums:"ok,warning,error"`
Warnings []string `json:"warnings"`
Expand Down
1 change: 1 addition & 0 deletions coderd/healthcheck/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const (

// @typescript-generate DatabaseReport
type DatabaseReport struct {
// Healthy is left for backward compatibility purposes, use `Severity` instead.
Healthy bool `json:"healthy"`
Severity health.Severity `json:"severity" enums:"ok,warning,error"`
Warnings []string `json:"warnings"`
Expand Down
8 changes: 7 additions & 1 deletion coderd/healthcheck/derphealth/derp.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const (

// @typescript-generate Report
type Report struct {
// Healthy is left for backward compatibility purposes, use `Severity` instead.
Healthy bool `json:"healthy"`
Severity health.Severity `json:"severity" enums:"ok,warning,error"`
Warnings []string `json:"warnings"`
Expand All @@ -51,6 +52,7 @@ type Report struct {
type RegionReport struct {
mu sync.Mutex

// Healthy is left for backward compatibility purposes, use `Severity` instead.
Healthy bool `json:"healthy"`
Severity health.Severity `json:"severity" enums:"ok,warning,error"`
Warnings []string `json:"warnings"`
Expand All @@ -65,6 +67,7 @@ type NodeReport struct {
mu sync.Mutex
clientCounter int

// Healthy is left for backward compatibility purposes, use `Severity` instead.
Healthy bool `json:"healthy"`
Severity health.Severity `json:"severity" enums:"ok,warning,error"`
Warnings []string `json:"warnings"`
Expand Down Expand Up @@ -171,6 +174,7 @@ func (r *RegionReport) Run(ctx context.Context) {
defer func() {
if err := recover(); err != nil {
nodeReport.Error = ptr.Ref(fmt.Sprint(err))
nodeReport.Severity = health.SeverityError
}
}()

Expand Down Expand Up @@ -226,6 +230,7 @@ func (r *NodeReport) Run(ctx context.Context) {
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()

r.Severity = health.SeverityOK
r.ClientLogs = [][]string{}
r.ClientErrs = [][]string{}

Expand All @@ -248,11 +253,12 @@ func (r *NodeReport) Run(ctx context.Context) {
// The node was marked as STUN compatible but the STUN test failed.
r.STUN.Error != nil {
r.Healthy = false
r.Severity = health.SeverityError
}

if r.UsesWebsocket {
r.Warnings = append(r.Warnings, warningNodeUsesWebsocket)
// FIXME
r.Severity = health.SeverityWarning
}
}

Expand Down
1 change: 1 addition & 0 deletions coderd/healthcheck/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type WebsocketReportOptions struct {

// @typescript-generate WebsocketReport
type WebsocketReport struct {
// Healthy is left for backward compatibility purposes, use `Severity` instead.
Healthy bool `json:"healthy"`
Severity health.Severity `json:"severity" enums:"ok,warning,error"`
Warnings []string `json:"warnings"`
Expand Down
Loading