mirror of
https://github.com/coder/coder.git
synced 2025-07-08 11:39:50 +00:00
fix: return non-null warning arrays in healthcheck (#10774)
This commit is contained in:
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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{}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ func TestHealthcheck(t *testing.T) {
|
||||
},
|
||||
},
|
||||
healthy: true,
|
||||
failingSections: nil,
|
||||
failingSections: []string{},
|
||||
}, {
|
||||
name: "DERPFail",
|
||||
checker: &testChecker{
|
||||
@ -95,7 +95,7 @@ func TestHealthcheck(t *testing.T) {
|
||||
},
|
||||
},
|
||||
healthy: true,
|
||||
failingSections: nil,
|
||||
failingSections: []string{},
|
||||
}, {
|
||||
name: "AccessURLFail",
|
||||
checker: &testChecker{
|
||||
|
@ -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))
|
||||
|
Reference in New Issue
Block a user