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
Reports
  • Loading branch information
mtojek committed Nov 22, 2023
commit 6c59dc3b7f6fe1ede9246a1c8f1f36b09435db53
8 changes: 8 additions & 0 deletions coderd/healthcheck/derphealth/derp.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ func (r *Report) Run(ctx context.Context, opts *ReportOptions) {

func (r *RegionReport) Run(ctx context.Context) {
r.Healthy = true
r.Severity = health.SeverityOK
r.NodeReports = []*NodeReport{}

wg := &sync.WaitGroup{}
Expand Down Expand Up @@ -205,6 +206,13 @@ func (r *RegionReport) Run(ctx context.Context) {
} else if healthyNodes < len(r.Region.Nodes) {
r.Warnings = append(r.Warnings, oneNodeUnhealthy)
}

// Review node reports and select the highest severing.
for _, nodeReport := range r.NodeReports {
if nodeReport.Severity.Value() > r.Severity.Value() {
r.Severity = nodeReport.Severity
}
}
}

func (r *NodeReport) derpURL() *url.URL {
Expand Down
10 changes: 10 additions & 0 deletions coderd/healthcheck/health/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,13 @@ const (

// @typescript-generate Severity
type Severity string

var severityRank = map[Severity]int{
SeverityOK: 0,
SeverityWarning: 1,
SeverityError: 2,
}

func (s Severity) Value() int {
return severityRank[s]
}
16 changes: 16 additions & 0 deletions coderd/healthcheck/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,22 @@ func Run(ctx context.Context, opts *ReportOptions) *Report {
}

report.Healthy = len(report.FailingSections) == 0

// Review healthcheck sub-reports.
report.Severity = health.SeverityOK

if report.DERP.Severity.Value() > report.Severity.Value() {
report.Severity = report.DERP.Severity
}
if report.AccessURL.Severity.Value() > report.Severity.Value() {
report.Severity = report.AccessURL.Severity
}
if report.Websocket.Severity.Value() > report.Severity.Value() {
report.Severity = report.Websocket.Severity
}
if report.Database.Severity.Value() > report.Severity.Value() {
report.Severity = report.Database.Severity
}
return &report
}

Expand Down