mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
fix(coderd/healthcheck/derphealth): avoid data races in DERP report (#24795)
Fixes two data races, one introduced in #24544 and one pre-existing. Related to: https://github.com/coder/internal/issues/1505
This commit is contained in:
@@ -113,13 +113,6 @@ func (r *Report) Run(ctx context.Context, opts *ReportOptions) {
|
||||
mu.Unlock()
|
||||
}()
|
||||
}
|
||||
if !hasDERP {
|
||||
r.Severity = health.SeverityWarning
|
||||
r.Warnings = append(r.Warnings, health.Messagef(
|
||||
health.CodeDERPNoNodes, noDERP,
|
||||
))
|
||||
}
|
||||
|
||||
ncLogf := func(format string, args ...interface{}) {
|
||||
mu.Lock()
|
||||
r.NetcheckLogs = append(r.NetcheckLogs, fmt.Sprintf(format, args...))
|
||||
@@ -134,11 +127,20 @@ func (r *Report) Run(ctx context.Context, opts *ReportOptions) {
|
||||
r.Netcheck = ncReport
|
||||
r.NetcheckErr = convertError(netcheckErr)
|
||||
if mapVaryDest, _ := r.Netcheck.MappingVariesByDestIP.Get(); mapVaryDest {
|
||||
mu.Lock()
|
||||
r.Warnings = append(r.Warnings, health.Messagef(health.CodeSTUNMapVaryDest, stunMapVaryDest))
|
||||
mu.Unlock()
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
|
||||
if !hasDERP {
|
||||
r.Severity = health.SeverityWarning
|
||||
r.Warnings = append(r.Warnings, health.Messagef(
|
||||
health.CodeDERPNoNodes, noDERP,
|
||||
))
|
||||
}
|
||||
|
||||
// Count the number of STUN-capable nodes.
|
||||
var stunCapableNodes int
|
||||
var stunTotalNodes int
|
||||
|
||||
Reference in New Issue
Block a user