mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-25 20:23:43 +00:00
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:
13
tsd/tsd.go
13
tsd/tsd.go
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user