Skip to content

fix: return non-null warning arrays in healthcheck #10774

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 1 commit into from
Nov 17, 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
fix(healthcheck): return non-null warning arrays
  • Loading branch information
coadler committed Nov 17, 2023
commit 894e9373e3353eb3fd1750849e4c3faa0f445be9
1 change: 1 addition & 0 deletions coderd/healthcheck/accessurl.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func (r *AccessURLReport) Run(ctx context.Context, opts *AccessURLReportOptions)
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()

r.Warnings = []string{}
if opts.AccessURL == nil {
r.Error = ptr.Ref("access URL is nil")
return
Expand Down
1 change: 1 addition & 0 deletions coderd/healthcheck/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type DatabaseReportOptions struct {
}

func (r *DatabaseReport) Run(ctx context.Context, opts *DatabaseReportOptions) {
r.Warnings = []string{}
r.ThresholdMS = opts.Threshold.Milliseconds()
if r.ThresholdMS == 0 {
r.ThresholdMS = DatabaseDefaultThreshold.Milliseconds()
Expand Down
1 change: 1 addition & 0 deletions coderd/healthcheck/derphealth/derp.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ type ReportOptions struct {
func (r *Report) Run(ctx context.Context, opts *ReportOptions) {
r.Healthy = true
r.Regions = map[int]*RegionReport{}
r.Warnings = []string{}

wg := &sync.WaitGroup{}
mu := sync.Mutex{}
Expand Down
1 change: 1 addition & 0 deletions coderd/healthcheck/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func Run(ctx context.Context, opts *ReportOptions) *Report {
wg.Wait()

report.Time = time.Now()
report.FailingSections = []string{}
if !report.DERP.Healthy {
report.FailingSections = append(report.FailingSections, SectionDERP)
}
Expand Down
4 changes: 2 additions & 2 deletions coderd/healthcheck/healthcheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestHealthcheck(t *testing.T) {
},
},
healthy: true,
failingSections: nil,
failingSections: []string{},
}, {
name: "DERPFail",
checker: &testChecker{
Expand Down Expand Up @@ -95,7 +95,7 @@ func TestHealthcheck(t *testing.T) {
},
},
healthy: true,
failingSections: nil,
failingSections: []string{},
}, {
name: "AccessURLFail",
checker: &testChecker{
Expand Down
1 change: 1 addition & 0 deletions coderd/healthcheck/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func (r *WebsocketReport) Run(ctx context.Context, opts *WebsocketReportOptions)
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()

r.Warnings = []string{}
u, err := opts.AccessURL.Parse("/api/v2/debug/ws")
if err != nil {
r.Error = convertError(xerrors.Errorf("parse access url: %w", err))
Expand Down