mirror of
https://github.com/tailscale/tailscale.git
synced 2025-05-03 14:11:02 +00:00
health: fix data race in new warnable code
Fixes #12479 Change-Id: Ice84d5eb12d835eeddf6fc8cc337ea6b4dddcf6c Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
c32efd9118
commit
7bc9d453c2
@ -124,15 +124,8 @@ const (
|
|||||||
|
|
||||||
var subsystemsWarnables = map[Subsystem]*Warnable{}
|
var subsystemsWarnables = map[Subsystem]*Warnable{}
|
||||||
|
|
||||||
const legacyErrorArgKey = "LegacyError"
|
func init() {
|
||||||
|
for _, s := range []Subsystem{SysRouter, SysDNS, SysDNSOS, SysDNSManager, SysTKA} {
|
||||||
// Warnable() returns a Warnable representing a legacy Subsystem. This is used
|
|
||||||
// *temporarily* while we migrate the old health infrastructure based on
|
|
||||||
// Subsystems to the new Warnables architecture.
|
|
||||||
func (s Subsystem) Warnable() *Warnable {
|
|
||||||
if w, ok := subsystemsWarnables[s]; ok {
|
|
||||||
return w
|
|
||||||
} else {
|
|
||||||
w := Register(&Warnable{
|
w := Register(&Warnable{
|
||||||
Code: WarnableCode(s),
|
Code: WarnableCode(s),
|
||||||
Severity: SeverityMedium,
|
Severity: SeverityMedium,
|
||||||
@ -141,10 +134,22 @@ func (s Subsystem) Warnable() *Warnable {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
subsystemsWarnables[s] = w
|
subsystemsWarnables[s] = w
|
||||||
return w
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const legacyErrorArgKey = "LegacyError"
|
||||||
|
|
||||||
|
// Warnable returns a Warnable representing a legacy Subsystem. This is used
|
||||||
|
// temporarily (2024-06-14) while we migrate the old health infrastructure based
|
||||||
|
// on Subsystems to the new Warnables architecture.
|
||||||
|
func (s Subsystem) Warnable() *Warnable {
|
||||||
|
w, ok := subsystemsWarnables[s]
|
||||||
|
if !ok {
|
||||||
|
panic(fmt.Sprintf("health: no Warnable for Subsystem %q", s))
|
||||||
|
}
|
||||||
|
return w
|
||||||
|
}
|
||||||
|
|
||||||
var registeredWarnables = map[WarnableCode]*Warnable{}
|
var registeredWarnables = map[WarnableCode]*Warnable{}
|
||||||
|
|
||||||
// Register registers a new Warnable with the health package and returns it.
|
// Register registers a new Warnable with the health package and returns it.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user