Skip to content

Commit 894e937

Browse files
committed
fix(healthcheck): return non-null warning arrays
1 parent d19a762 commit 894e937

File tree

6 files changed

+7
-2
lines changed

6 files changed

+7
-2
lines changed

coderd/healthcheck/accessurl.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func (r *AccessURLReport) Run(ctx context.Context, opts *AccessURLReportOptions)
3333
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
3434
defer cancel()
3535

36+
r.Warnings = []string{}
3637
if opts.AccessURL == nil {
3738
r.Error = ptr.Ref("access URL is nil")
3839
return

coderd/healthcheck/database.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type DatabaseReportOptions struct {
3232
}
3333

3434
func (r *DatabaseReport) Run(ctx context.Context, opts *DatabaseReportOptions) {
35+
r.Warnings = []string{}
3536
r.ThresholdMS = opts.Threshold.Milliseconds()
3637
if r.ThresholdMS == 0 {
3738
r.ThresholdMS = DatabaseDefaultThreshold.Milliseconds()

coderd/healthcheck/derphealth/derp.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ type ReportOptions struct {
8989
func (r *Report) Run(ctx context.Context, opts *ReportOptions) {
9090
r.Healthy = true
9191
r.Regions = map[int]*RegionReport{}
92+
r.Warnings = []string{}
9293

9394
wg := &sync.WaitGroup{}
9495
mu := sync.Mutex{}

coderd/healthcheck/healthcheck.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ func Run(ctx context.Context, opts *ReportOptions) *Report {
136136
wg.Wait()
137137

138138
report.Time = time.Now()
139+
report.FailingSections = []string{}
139140
if !report.DERP.Healthy {
140141
report.FailingSections = append(report.FailingSections, SectionDERP)
141142
}

coderd/healthcheck/healthcheck_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func TestHealthcheck(t *testing.T) {
5858
},
5959
},
6060
healthy: true,
61-
failingSections: nil,
61+
failingSections: []string{},
6262
}, {
6363
name: "DERPFail",
6464
checker: &testChecker{
@@ -95,7 +95,7 @@ func TestHealthcheck(t *testing.T) {
9595
},
9696
},
9797
healthy: true,
98-
failingSections: nil,
98+
failingSections: []string{},
9999
}, {
100100
name: "AccessURLFail",
101101
checker: &testChecker{

coderd/healthcheck/websocket.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func (r *WebsocketReport) Run(ctx context.Context, opts *WebsocketReportOptions)
3333
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
3434
defer cancel()
3535

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

0 commit comments

Comments
 (0)