health: always include control health messages in the current state
(*health.Tracker).CurrentState() returns an empty state when there are no client-side warnables, even when there are control-health messages, which is incorrect. This fixes it. Updates tailscale/corp#37275 Signed-off-by: Nick Khyl <nickk@tailscale.com>
This commit is contained in:
+4
-7
@@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
"tailscale.com/feature/buildfeatures"
|
"tailscale.com/feature/buildfeatures"
|
||||||
"tailscale.com/tailcfg"
|
"tailscale.com/tailcfg"
|
||||||
|
"tailscale.com/util/mak"
|
||||||
)
|
)
|
||||||
|
|
||||||
// State contains the health status of the backend, and is
|
// State contains the health status of the backend, and is
|
||||||
@@ -128,11 +129,7 @@ func (t *Tracker) CurrentState() *State {
|
|||||||
t.mu.Lock()
|
t.mu.Lock()
|
||||||
defer t.mu.Unlock()
|
defer t.mu.Unlock()
|
||||||
|
|
||||||
if t.warnableVal == nil || len(t.warnableVal) == 0 {
|
var wm map[WarnableCode]UnhealthyState
|
||||||
return &State{}
|
|
||||||
}
|
|
||||||
|
|
||||||
wm := map[WarnableCode]UnhealthyState{}
|
|
||||||
|
|
||||||
for w, ws := range t.warnableVal {
|
for w, ws := range t.warnableVal {
|
||||||
if !w.IsVisible(ws, t.now) {
|
if !w.IsVisible(ws, t.now) {
|
||||||
@@ -145,7 +142,7 @@ func (t *Tracker) CurrentState() *State {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
state := w.unhealthyState(ws)
|
state := w.unhealthyState(ws)
|
||||||
wm[w.Code] = state.withETag()
|
mak.Set(&wm, w.Code, state.withETag())
|
||||||
}
|
}
|
||||||
|
|
||||||
for id, msg := range t.lastNotifiedControlMessages {
|
for id, msg := range t.lastNotifiedControlMessages {
|
||||||
@@ -165,7 +162,7 @@ func (t *Tracker) CurrentState() *State {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wm[state.WarnableCode] = state.withETag()
|
mak.Set(&wm, state.WarnableCode, state.withETag())
|
||||||
}
|
}
|
||||||
|
|
||||||
return &State{
|
return &State{
|
||||||
|
|||||||
Reference in New Issue
Block a user