health,ipn/ipnlocal: introduce eventbus in heath.Tracker (#17085)

The Tracker was using direct callbacks to ipnlocal. This PR moves those
to be triggered via the eventbus.

Additionally, the eventbus is now closed on exit from tailscaled
explicitly, and health is now a SubSystem in tsd.

Updates #15160

Signed-off-by: Claus Lensbøl <claus@tailscale.com>
This commit is contained in:
Claus Lensbøl
2025-09-16 11:25:29 -04:00
committed by GitHub
parent 4cca9f7c67
commit 2015ce4081
37 changed files with 404 additions and 245 deletions

View File

@@ -60,6 +60,7 @@ type System struct {
DriveForLocal SubSystem[drive.FileSystemForLocal]
DriveForRemote SubSystem[drive.FileSystemForRemote]
PolicyClient SubSystem[policyclient.Client]
HealthTracker SubSystem[*health.Tracker]
// InitialConfig is initial server config, if any.
// It is nil if the node is not in declarative mode.
@@ -74,7 +75,6 @@ type System struct {
controlKnobs controlknobs.Knobs
proxyMap proxymap.Mapper
healthTracker health.Tracker
userMetricsRegistry usermetric.Registry
}
@@ -91,6 +91,10 @@ func NewSystemWithBus(bus *eventbus.Bus) *System {
}
sys := new(System)
sys.Set(bus)
tracker := health.NewTracker(bus)
sys.Set(tracker)
return sys
}
@@ -138,6 +142,8 @@ func (s *System) Set(v any) {
s.DriveForRemote.Set(v)
case policyclient.Client:
s.PolicyClient.Set(v)
case *health.Tracker:
s.HealthTracker.Set(v)
default:
panic(fmt.Sprintf("unknown type %T", v))
}
@@ -167,11 +173,6 @@ func (s *System) ProxyMapper() *proxymap.Mapper {
return &s.proxyMap
}
// HealthTracker returns the system health tracker.
func (s *System) HealthTracker() *health.Tracker {
return &s.healthTracker
}
// UserMetricsRegistry returns the system usermetrics.
func (s *System) UserMetricsRegistry() *usermetric.Registry {
return &s.userMetricsRegistry