mirror of
https://github.com/coder/coder.git
synced 2025-07-09 11:45:56 +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)
|
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
|
||||||
|
@ -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()
|
||||||
|
@ -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{}
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
|
@ -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{
|
||||||
|
@ -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))
|
||||||
|
Reference in New Issue
Block a user