health: do Warnable dependency filtering in tailscaled
Previously we were depending on the GUI(s) to do it. By doing it in tailscaled, GUIs can be simplified and be guaranteed to render consistent results. If warnable A depends on warnable B, if both A & B are unhealhy, only B will be shown to the GUI as unhealthy. Once B clears up, only then will A be presented as unhealthy. Updates #14687 Change-Id: Id8566f2672d8d2d699740fa053d4e2a2c8009e83 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
76dc028b38
commit
bfde8079a0
@@ -90,6 +90,11 @@ func (t *Tracker) CurrentState() *State {
|
||||
// Skip invisible Warnables.
|
||||
continue
|
||||
}
|
||||
if t.isEffectivelyHealthyLocked(w) {
|
||||
// Skip Warnables that are unhealthy if they have dependencies
|
||||
// that are unhealthy.
|
||||
continue
|
||||
}
|
||||
wm[w.Code] = *w.unhealthyState(ws)
|
||||
}
|
||||
|
||||
@@ -97,3 +102,23 @@ func (t *Tracker) CurrentState() *State {
|
||||
Warnings: wm,
|
||||
}
|
||||
}
|
||||
|
||||
// isEffectivelyHealthyLocked reports whether w is effectively healthy.
|
||||
// That means it's either actually healthy or it has a dependency that
|
||||
// that's unhealthy, so we should treat w as healthy to not spam users
|
||||
// with multiple warnings when only the root cause is relevant.
|
||||
func (t *Tracker) isEffectivelyHealthyLocked(w *Warnable) bool {
|
||||
if _, ok := t.warnableVal[w]; !ok {
|
||||
// Warnable not found in the tracker. So healthy.
|
||||
return true
|
||||
}
|
||||
for _, d := range w.DependsOn {
|
||||
if !t.isEffectivelyHealthyLocked(d) {
|
||||
// If one of our deps is unhealthy, we're healthy.
|
||||
return true
|
||||
}
|
||||
}
|
||||
// If we have no unhealthy deps and had warnableVal set,
|
||||
// we're unhealthy.
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user