From e475c589e6ed67ce1262732badff969f47a2a85f Mon Sep 17 00:00:00 2001 From: James Sanderson Date: Thu, 17 Apr 2025 19:36:55 +0100 Subject: [PATCH] wip, health status icons now work --- health/health.go | 18 +++++++----------- ipn/ipnlocal/local.go | 17 ++++++++--------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/health/health.go b/health/health.go index 714c5859c..d0102bace 100644 --- a/health/health.go +++ b/health/health.go @@ -455,6 +455,12 @@ func (t *Tracker) setHealthyLocked(w *Warnable) { } } +func (t *Tracker) notifyWatchersLocked() { + for _, cb := range t.watchers { + go cb(nil, nil) + } +} + // AppendWarnableDebugFlags appends to base any health items that are currently in failed // state and were created with MapDebugFlag. func (t *Tracker) AppendWarnableDebugFlags(base []string) []string { @@ -647,6 +653,7 @@ func (t *Tracker) SetControlHealth(problems []tailcfg.Health) { defer t.mu.Unlock() t.controlHealth = problems t.selfCheckLocked() + t.notifyWatchersLocked() } // GotStreamedMapResponse notes that we got a tailcfg.MapResponse @@ -1151,17 +1158,6 @@ func (t *Tracker) updateBuiltinWarnablesLocked() { t.setHealthyLocked(derpRegionErrorWarnable) } - 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) - } - } - if err := envknob.ApplyDiskConfigError(); err != nil { t.setUnhealthyLocked(applyDiskConfigWarnable, Args{ ArgError: err.Error(), diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index c967cdab1..dec132c67 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -967,15 +967,14 @@ 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 { - b.logf("health(warnable=%s): error: %s", w.Code, us.Text) - } +func (b *LocalBackend) onHealthChange(_ *health.Warnable, us *health.UnhealthyState) { + // if w != nil { + // if us == nil { + // b.logf("health(warnable=%s): ok", w.Code) + // } else { + // b.logf("health(warnable=%s): error: %s", w.Code, us.Text) + // } + // } // Whenever health changes, send the current health state to the frontend. state := b.health.CurrentState()