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) ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel() defer cancel()
r.Warnings = []string{}
if opts.AccessURL == nil { if opts.AccessURL == nil {
r.Error = ptr.Ref("access URL is nil") r.Error = ptr.Ref("access URL is nil")
return return

View File

@ -32,6 +32,7 @@ type DatabaseReportOptions struct {
} }
func (r *DatabaseReport) Run(ctx context.Context, opts *DatabaseReportOptions) { func (r *DatabaseReport) Run(ctx context.Context, opts *DatabaseReportOptions) {
r.Warnings = []string{}
r.ThresholdMS = opts.Threshold.Milliseconds() r.ThresholdMS = opts.Threshold.Milliseconds()
if r.ThresholdMS == 0 { if r.ThresholdMS == 0 {
r.ThresholdMS = DatabaseDefaultThreshold.Milliseconds() r.ThresholdMS = DatabaseDefaultThreshold.Milliseconds()

View File

@ -89,6 +89,7 @@ type ReportOptions struct {
func (r *Report) Run(ctx context.Context, opts *ReportOptions) { func (r *Report) Run(ctx context.Context, opts *ReportOptions) {
r.Healthy = true r.Healthy = true
r.Regions = map[int]*RegionReport{} r.Regions = map[int]*RegionReport{}
r.Warnings = []string{}
wg := &sync.WaitGroup{} wg := &sync.WaitGroup{}
mu := sync.Mutex{} mu := sync.Mutex{}

View File

@ -136,6 +136,7 @@ func Run(ctx context.Context, opts *ReportOptions) *Report {
wg.Wait() wg.Wait()
report.Time = time.Now() report.Time = time.Now()
report.FailingSections = []string{}
if !report.DERP.Healthy { if !report.DERP.Healthy {
report.FailingSections = append(report.FailingSections, SectionDERP) report.FailingSections = append(report.FailingSections, SectionDERP)
} }

View File

@ -58,7 +58,7 @@ func TestHealthcheck(t *testing.T) {
}, },
}, },
healthy: true, healthy: true,
failingSections: nil, failingSections: []string{},
}, { }, {
name: "DERPFail", name: "DERPFail",
checker: &testChecker{ checker: &testChecker{
@ -95,7 +95,7 @@ func TestHealthcheck(t *testing.T) {
}, },
}, },
healthy: true, healthy: true,
failingSections: nil, failingSections: []string{},
}, { }, {
name: "AccessURLFail", name: "AccessURLFail",
checker: &testChecker{ 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) ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel() defer cancel()
r.Warnings = []string{}
u, err := opts.AccessURL.Parse("/api/v2/debug/ws") u, err := opts.AccessURL.Parse("/api/v2/debug/ws")
if err != nil { if err != nil {
r.Error = convertError(xerrors.Errorf("parse access url: %w", err)) r.Error = convertError(xerrors.Errorf("parse access url: %w", err))