health: hide warnables while the backend is warming up

Since bfde8079a, the Tracker omits warnables with an unhealthy
dependency from CurrentState and Strings. But that only covered
Warnable.DependsOn. The implicit dependency on the warming-up warnable
was still only advertised via UnhealthyState.DependsOn and left to
clients to enforce. The macOS, iOS and Android clients did; the Windows
clients and the CLI did not, and showed warnings that disappeared once
the backend started.

Enforce it in the Tracker as well, so that all clients behave the same
and do not need to inspect DependsOn.

Updates tailscale/corp#44572
Updates #14796
Updates #14687

Signed-off-by: Nick Khyl <[email protected]>
This commit is contained in:
Nick Khyl authored and Nick Khyl committed 2026-11-17 11:30:51 -08:00
1 parent 153f00f636
commit 7c6e49dfb3
5 files changed
+51 -10

No files matched your search

@@ -169,6 +169,8 @@ func TestExitNodeResponsivenessLifecycle(t *testing.T) {
e.evaluateResponsiveness(now)
e.mu.Unlock()
}
// End the warm-up period, during which warnings are hidden.
b.HealthTracker().SetIPNState(ipn.Running.String(), true)
w := b.HealthTracker().CurrentState().Warnings[exitNodeUnresponsiveWarnable.Code]
want := "The selected exit node \"my-gateway\" has not responded since " + start.WallTime().UTC().Format(time.RFC3339) + ". Internet connectivity may be affected."
if w.Text != want {
+3 -4
View File
@@ -269,10 +269,9 @@ type Warnable struct {
// the Args of the unhappy state, just like we do in the Text function.
Severity Severity
// DependsOn is a set of Warnables that this Warnable depends on and need to be healthy
// before this Warnable is relevant. The GUI can use this information to ignore
// this Warnable if one of its dependencies is unhealthy.
// That is, if any of these Warnables are unhealthy, then this Warnable is not relevant
// and should be considered healthy to bother the user about.
// before this Warnable is relevant. If any of these Warnables are unhealthy, the [Tracker]
// treats this Warnable as healthy and omits it from [State] and [Tracker.Strings],
// so clients do not need to check the dependencies themselves.
DependsOn []*Warnable
// MapDebugFlag is a MapRequest.DebugFlag that is sent to control when this Warnable is unhealthy
+39 -1
View File
@@ -449,6 +449,44 @@ func TestCheckDependsOnAppearsInUnhealthyState(t *testing.T) {
}
}
// TestWarmingUpHidesOtherWarnables asserts that unhealthy Warnables are omitted from
// [Tracker.CurrentState] and [Tracker.Strings] while the backend is warming up.
func TestWarmingUpHidesOtherWarnables(t *testing.T) {
ht := NewTracker(eventbustest.NewBus(t))
w := Register(&Warnable{
Code: "w",
Text: StaticMessage("W Text"),
})
defer unregister(w)
ht.SetIPNState("Starting", true)
ht.SetUnhealthy(w, nil)
warnings := ht.CurrentState().Warnings
if _, ok := warnings[warmingUpWarnable.Code]; !ok {
t.Fatalf("warming-up warnable is not unhealthy; want unhealthy")
}
if _, ok := warnings[w.Code]; ok {
t.Errorf("w is unhealthy while warming up; want it hidden")
}
if got := ht.Strings(); slices.Contains(got, "W Text") {
t.Errorf("Strings() = %q while warming up; want w hidden", got)
}
ht.SetIPNState("Running", true)
warnings = ht.CurrentState().Warnings
if _, ok := warnings[warmingUpWarnable.Code]; ok {
t.Errorf("warming-up warnable is unhealthy in Running state; want healthy")
}
if _, ok := warnings[w.Code]; !ok {
t.Errorf("w is not unhealthy after warming up; want unhealthy")
}
if got := ht.Strings(); !slices.Contains(got, "W Text") {
t.Errorf("Strings() = %q after warming up; want w included", got)
}
}
func TestShowUpdateWarnable(t *testing.T) {
tests := []struct {
desc string
@@ -1003,7 +1041,7 @@ func TestCurrentStateETagWarnable(t *testing.T) {
newTracker := func(clock tstime.Clock) *Tracker {
ht := NewTracker(eventbustest.NewBus(t))
ht.testClock = clock
ht.SetIPNState("NeedsLogin", true)
ht.SetIPNState("Running", true)
ht.GotStreamedMapResponse()
return ht
}
+6 -3
View File
@@ -98,9 +98,8 @@ func (w *Warnable) unhealthyState(ws *warningState) *UnhealthyState {
}
if w != warmingUpWarnable {
// Here we tell the frontend that all Warnables depend on warmingUpWarnable. GUIs will silence all warnings until all
// their dependencies are healthy. This is a special case to prevent the GUI from showing a bunch of warnings when
// the backend is still warming up.
// All Warnables implicitly depend on warmingUpWarnable, so that we don't show a bunch of warnings
// while the backend is still warming up. See [Tracker.isEffectivelyHealthyLocked].
dependsOnWarnableCodes = append(dependsOnWarnableCodes, warmingUpWarnable.Code)
}
@@ -190,6 +189,10 @@ func (t *Tracker) isEffectivelyHealthyLocked(w *Warnable) bool {
// Warnable not found in the tracker. So healthy.
return true
}
if w != warmingUpWarnable && t.warnableVal[warmingUpWarnable] != nil {
// Every Warnable implicitly depends on warmingUpWarnable.
return true
}
for _, d := range w.DependsOn {
if !t.isEffectivelyHealthyLocked(d) {
// If one of our deps is unhealthy, we're healthy.
+1 -2
View File
@@ -288,8 +288,7 @@ var applyDiskConfigWarnable = condRegister(func() *Warnable {
const warmingUpWarnableDuration = 5 * time.Second
// warmingUpWarnable is a Warnable that is reported by the backend when it is starting up, for a maximum time of
// warmingUpWarnableDuration. The GUIs use the presence of this Warnable to prevent showing any other warnings until
// the backend is fully started.
// warmingUpWarnableDuration. While it is unhealthy, the [Tracker] treats all other Warnables as healthy.
var warmingUpWarnable = condRegister(func() *Warnable {
return &Warnable{
Code: tsconst.HealthWarnableWarmingUp,