attempting to make healthv2 warnables work better

This commit is contained in:
James Sanderson 2025-04-15 13:56:38 +01:00
parent 5a9259553a
commit 07b98db2bc
4 changed files with 26 additions and 13 deletions

View File

@ -1614,6 +1614,10 @@ func postPingResult(start time.Time, logf logger.Logf, c *http.Client, pr *tailc
// ReportHealthChange reports to the control plane a change to this node's
// health. w must be non-nil. us can be nil to indicate a healthy state for w.
func (c *Direct) ReportHealthChange(w *health.Warnable, us *health.UnhealthyState) {
// TODO: Don't tell control about health messages that came from control?
if w == nil {
return
}
if w == health.NetworkStatusWarnable || w == health.IPNStateWarnable || w == health.LoginStateWarnable {
// We don't report these. These include things like the network is down
// (in which case we can't report anyway) or the user wanted things

View File

@ -1151,20 +1151,15 @@ func (t *Tracker) updateBuiltinWarnablesLocked() {
t.setHealthyLocked(derpRegionErrorWarnable)
}
if len(t.controlHealth) > 0 {
for _, s := range t.controlHealth {
t.setUnhealthyLocked(&Warnable{
Code: WarnableCode(s.ID),
Title: s.Title,
Text: func(args Args) string {
return s.Text
},
Severity: SeverityHigh,
ImpactsConnectivity: s.ImpactsConnectivity,
}, nil)
if t.controlHealth != nil {
// for _, cb := range t.watchers {
// go cb(nil, nil)
// }
if len(t.controlHealth) > 0 {
t.setUnhealthyLocked(controlHealthWarnable, nil)
} else {
t.setHealthyLocked(controlHealthWarnable)
}
} else {
t.setHealthyLocked(controlHealthWarnable)
}
if err := envknob.ApplyDiskConfigError(); err != nil {

View File

@ -100,6 +100,17 @@ func (t *Tracker) CurrentState() *State {
wm[w.Code] = *w.unhealthyState(ws)
}
for _, h := range t.controlHealth {
wm[WarnableCode(h.ID)] = UnhealthyState{
WarnableCode: WarnableCode(h.ID),
Severity: SeverityHigh,
Title: h.Title,
Text: h.Text,
ImpactsConnectivity: h.ImpactsConnectivity,
URL: h.URL,
}
}
return &State{
Warnings: wm,
}

View File

@ -968,6 +968,9 @@ func (b *LocalBackend) linkChange(delta *netmon.ChangeDelta) {
}
func (b *LocalBackend) onHealthChange(w *health.Warnable, us *health.UnhealthyState) {
if w == nil {
return
}
if us == nil {
b.logf("health(warnable=%s): ok", w.Code)
} else {