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

This commit is contained in:
Colin Adler
2023-11-17 16:25:44 -06:00
committed by GitHub
parent 2c3ebc50cb
commit 3aef070959
6 changed files with 7 additions and 2 deletions

View File

@ -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

View File

@ -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()

View File

@ -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{}

View File

@ -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)
}

View File

@ -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{

View File

@ -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))