mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-12 00:52:00 +00:00
control/controlclient,health,tailcfg: refactor control health messages (#15839)
* control/controlclient,health,tailcfg: refactor control health messages Updates tailscale/corp#27759 Signed-off-by: James Sanderson <jsanderson@tailscale.com> Signed-off-by: Paul Scott <408401+icio@users.noreply.github.com> Co-authored-by: Paul Scott <408401+icio@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
980ab4244d
commit
aa8bc23c49
@@ -5,6 +5,8 @@ package health
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"tailscale.com/tailcfg"
|
||||
)
|
||||
|
||||
// State contains the health status of the backend, and is
|
||||
@@ -21,7 +23,8 @@ type State struct {
|
||||
}
|
||||
|
||||
// UnhealthyState contains information to be shown to the user to inform them
|
||||
// that a Warnable is currently unhealthy.
|
||||
// that a [Warnable] is currently unhealthy or [tailcfg.DisplayMessage] is being
|
||||
// sent from the control-plane.
|
||||
type UnhealthyState struct {
|
||||
WarnableCode WarnableCode
|
||||
Severity Severity
|
||||
@@ -98,11 +101,34 @@ func (t *Tracker) CurrentState() *State {
|
||||
wm[w.Code] = *w.unhealthyState(ws)
|
||||
}
|
||||
|
||||
for id, msg := range t.lastNotifiedControlMessages {
|
||||
code := WarnableCode(id)
|
||||
wm[code] = UnhealthyState{
|
||||
WarnableCode: code,
|
||||
Severity: severityFromTailcfg(msg.Severity),
|
||||
Title: msg.Title,
|
||||
Text: msg.Text,
|
||||
ImpactsConnectivity: msg.ImpactsConnectivity,
|
||||
// TODO(tailscale/corp#27759): DependsOn?
|
||||
}
|
||||
}
|
||||
|
||||
return &State{
|
||||
Warnings: wm,
|
||||
}
|
||||
}
|
||||
|
||||
func severityFromTailcfg(s tailcfg.DisplayMessageSeverity) Severity {
|
||||
switch s {
|
||||
case tailcfg.SeverityHigh:
|
||||
return SeverityHigh
|
||||
case tailcfg.SeverityLow:
|
||||
return SeverityLow
|
||||
default:
|
||||
return SeverityMedium
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user