Movatterモバイル変換


[0]ホーム

URL:


health

package
v1.92.2Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2025 License:BSD-3-ClauseImports:27Imported by:25

Details

Repository

github.com/tailscale/tailscale

Links

Documentation

Overview

Package health is a registry for other packages to report & checkoverall health status of the node.

Index

Constants

View Source
const (// SysRouter is the name of the wgengine/router subsystem.SysRouter =Subsystem("router")// SysDNS is the name of the net/dns subsystem.SysDNS =Subsystem("dns")// SysDNSManager is the name of the net/dns manager subsystem.SysDNSManager =Subsystem("dns-manager")// SysTKA is the name of the tailnet key authority subsystem.SysTKA =Subsystem("tailnet-lock"))
View Source
const MetricLabelWarning = "warning"

Variables

View Source
var IPNStateWarnable = condRegister(func() *Warnable {return &Warnable{Code:tsconst.HealthWarnableWantRunningFalse,Title:    "Tailscale off",Severity:SeverityLow,Text:StaticMessage("Tailscale is stopped."),}})

IPNStateWarnable is a Warnable that warns the user that Tailscale is stopped.

View Source
var LoginStateWarnable = condRegister(func() *Warnable {return &Warnable{Code:tsconst.HealthWarnableLoginState,Title:    "Logged out",Severity:SeverityMedium,Text: func(argsArgs)string {if args[ArgError] != "" {returnfmt.Sprintf("You are logged out. The last login error was: %v", args[ArgError])} else {return "You are logged out."}},DependsOn: []*Warnable{IPNStateWarnable},}})

LoginStateWarnable is a Warnable that warns the user that they are logged out,and provides the last login error if available.

View Source
var NetworkStatusWarnable = condRegister(func() *Warnable {return &Warnable{Code:tsconst.HealthWarnableNetworkStatus,Title:               "Network down",Severity:SeverityMedium,Text:StaticMessage("Tailscale cannot connect because the network is down. Check your Internet connection."),ImpactsConnectivity:true,TimeToVisible:       5 *time.Second,}})

NetworkStatusWarnable is a Warnable that warns the user that the network is down.

Functions

funcDebugHandleradded inv1.20.0

func DebugHandler(typstring)http.Handler

funcRegisterDebugHandleradded inv1.20.0

func RegisterDebugHandler(typstring, hhttp.Handler)

funcStaticMessageadded inv1.70.0

func StaticMessage(sstring) func(Args)string

StaticMessage returns a function that always returns the input string, to be used insimple Warnables that do not use the Args map to generate their Text.

Types

typeArgadded inv1.70.0

type Argstring

Arg is a type for the key to be used in the Args of a Warnable.

const (// ArgAvailableVersion provides an update notification Warnable with the available version of the Tailscale client.ArgAvailableVersionArg = "available-version"// ArgCurrentVersion provides an update notification Warnable with the current version of the Tailscale client.ArgCurrentVersionArg = "current-version"// ArgDuration provides a Warnable with how long the Warnable has been in an unhealthy state.ArgDurationArg = "duration"// ArgError provides a Warnable with the underlying error behind an unhealthy state.ArgErrorArg = "error"// ArgMagicsockFunctionName provides a Warnable with the name of the Magicsock function that caused the unhealthy state.ArgMagicsockFunctionNameArg = "magicsock-function-name"// ArgDERPRegionID provides a Warnable with the ID of a DERP server involved in the unhealthy state.ArgDERPRegionIDArg = "derp-region-id"// ArgDERPRegionName provides a Warnable with the name of a DERP server involved in the unhealthy state.// It is used to show a more friendly message like "the Seattle relay server failed to connect" versus// "relay server 10 failed to connect".ArgDERPRegionNameArg = "derp-region-name"// ArgServerName provides a Warnable with the hostname of a server involved in the unhealthy state.ArgServerNameArg = "server-name"// ArgServerName provides a Warnable with comma delimited list of the hostname of the servers involved in the unhealthy state.// If no nameservers were available to query, this will be an empty string.ArgDNSServersArg = "dns-servers")

typeArgsadded inv1.70.0

type Args map[Arg]string

Args is a map of Args to string values that can be used to provide parameters regardingthe unhealthy state of a Warnable.For instance, if you have a Warnable to track the health of DNS lookups, here you can includethe hostname that failed to resolve, or the IP address of the DNS server that has been failingto respond. You can then use these parameters in the Text function of the Warnable to provide a detailederror message to the user.

typeChangeadded inv1.86.0

type Change struct {// ControlHealthChanged indicates it was health messages from the// control-plane server that changed.ControlHealthChangedbool// WarnableChanged indicates it was a client Warnable which changed state.WarnableChangedbool// Warnable is whose health changed, as indicated in UnhealthyState.Warnable *Warnable// UnhealthyState is set if the changed Warnable is now unhealthy, or nil// if Warnable is now healthy.UnhealthyState *UnhealthyState}

Change is used to communicate a change to health. This could either be due toa Warnable changing from health to unhealthy (or vice-versa), or because thehealth messages received from the control-plane have changed.

Exactly one *Changed field will be true.

typeReceiveFuncadded inv1.66.0

type ReceiveFuncint

ReceiveFunc is one of the three magicsock Receive funcs (IPv4, IPv6, orDERP).

const (ReceiveIPv4ReceiveFunc = 0ReceiveIPv6ReceiveFunc = 1ReceiveDERPReceiveFunc = 2)

ReceiveFunc indices for Tracker.MagicSockReceiveFuncs.

func (ReceiveFunc)Stringadded inv1.66.0

func (fReceiveFunc) String()string

typeReceiveFuncStatsadded inv1.8.0

type ReceiveFuncStats struct {// contains filtered or unexported fields}

ReceiveFuncStats tracks the calls made to a wireguard-go receive func.

func (*ReceiveFuncStats)Enteradded inv1.8.0

func (s *ReceiveFuncStats) Enter()

func (*ReceiveFuncStats)Exitadded inv1.8.0

func (s *ReceiveFuncStats) Exit()

func (*ReceiveFuncStats)Nameadded inv1.72.0

func (s *ReceiveFuncStats) Name()string

Name returns the name of the receive func ("ReceiveIPv4", "ReceiveIPv6", etc).

typeSeverityadded inv1.70.0

type Severitystring

Severity represents how serious an error is. Each GUI interprets this severity value in different ways,to surface the error in a more or less visible way. For instance, the macOS GUI could change its menubaricon to display an exclamation mark and present a modal notification for SeverityHigh warnings, but notfor SeverityLow messages, which would only appear in the Settings window.

const (// SeverityHigh is the highest severity level, used for critical errors that need immediate attention.// On platforms where the client GUI can deliver notifications, a SeverityHigh Warnable will trigger// a modal notification.SeverityHighSeverity = "high"// SeverityMedium is used for errors that are important but not critical. This won't trigger a modal// notification, however it will be displayed in a more visible way than a SeverityLow Warnable.SeverityMediumSeverity = "medium"// SeverityLow is used for less important notices that don't need immediate attention. The user will// have to go to a Settings window, or another "hidden" GUI location to see these messages.SeverityLowSeverity = "low")

typeStateadded inv1.70.0

type State struct {// Each key-value pair in Warnings represents a Warnable that is currently// unhealthy. If a Warnable is healthy, it will not be present in this map.// When a Warnable is unhealthy and becomes healthy, its key-value pair// disappears in the next issued State. Observers should treat the absence of// a WarnableCode in this map as an indication that the Warnable became healthy,// and may use that to clear any notifications that were previously shown to the user.// If Warnings is nil, all Warnables are healthy and the backend is overall healthy.Warnings map[WarnableCode]UnhealthyState}

State contains the health status of the backend, and isprovided to the client UI via LocalAPI through ipn.Notify.

It is also exposed via c2n for debugging purposes, so trynot to change its structure too gratuitously.

typeSubsystemdeprecatedadded inv1.6.0

type Subsystemstring

Subsystem is the name of a subsystem whose health can be monitored.

Deprecated: Registering a Warnable using Register() and updating its health statewith SetUnhealthy() and SetHealthy() should be preferred.

func (Subsystem)Warnableadded inv1.70.0

func (sSubsystem) Warnable() *Warnable

Warnable returns a Warnable representing a legacy Subsystem. This is usedtemporarily (2024-06-14) while we migrate the old health infrastructure basedon Subsystems to the new Warnables architecture.

typeTrackeradded inv1.66.0

type Tracker struct {// MagicSockReceiveFuncs tracks the state of the three// magicsock receive functions: IPv4, IPv6, and DERP.MagicSockReceiveFuncs [3]ReceiveFuncStats// indexed by ReceiveFunc values// contains filtered or unexported fields}

Tracker tracks the health of various Tailscale subsystems,comparing each subsystems' state with each other to make surethey're consistent based on the user's intended state.

If a clientWarnable becomes unhealthy or its unhealthy state is updated,an event will be emitted with WarnableChanged set to true and the Warnableand its UnhealthyState:

Change{WarnableChanged: true, Warnable: w, UnhealthyState: us}

If a Warnable becomes healthy, an event will be emitted withWarnableChanged set to true, the Warnable set, and UnhealthyState set to nil:

Change{WarnableChanged: true, Warnable: w, UnhealthyState: nil}

If the health messages from the control-plane change, an event will beemitted with ControlHealthChanged set to true. Recipients can fetch the set ofcontrol-plane health messages by callingTracker.CurrentState:

funcNewTrackeradded inv1.90.0

func NewTracker(bus *eventbus.Bus) *Tracker

NewTracker contructs a newTracker and attaches the given eventbus.NewTracker will panic is no eventbus is given.

func (*Tracker)AppendWarnableDebugFlagsadded inv1.66.0

func (t *Tracker) AppendWarnableDebugFlags(base []string) []string

AppendWarnableDebugFlags appends to base any health items that are currently in failedstate and were created with MapDebugFlag.

func (*Tracker)CurrentStateadded inv1.70.0

func (t *Tracker) CurrentState() *State

CurrentState returns a snapshot of the current health status of the backend.It returns a State with nil Warnings if the backend is healthy (all Warnableshave no issues).The returned State is a snapshot of shared memory, and the caller should notmutate the returned value.

func (*Tracker)DNSHealthdeprecatedadded inv1.66.0

func (t *Tracker) DNSHealth()error

DNSHealth returns the net/dns.Manager error state.

Deprecated: Warnables should be preferred over Subsystem errors.

func (*Tracker)GetDERPRegionReceivedTimeadded inv1.66.0

func (t *Tracker) GetDERPRegionReceivedTime(regionint)time.Time

GetDERPRegionReceivedTime returns the last time that a frame was receivedfrom the given DERP region, or the zero time if no communication with thatregion has occurred.

func (*Tracker)GetInPollNetMapadded inv1.66.0

func (t *Tracker) GetInPollNetMap()bool

GetInPollNetMap reports whether the client has an openHTTP long poll open to the control plane.

func (*Tracker)GotStreamedMapResponseadded inv1.66.0

func (t *Tracker) GotStreamedMapResponse()

GotStreamedMapResponse notes that we got a tailcfg.MapResponsemessage in streaming mode, even if it's just a keep-alive message.

This also notes that a map poll is in progress. To unset that, callSetOutOfPollNetMap().

func (*Tracker)IsUnhealthyadded inv1.84.0

func (t *Tracker) IsUnhealthy(w *Warnable)bool

IsUnhealthy reports whether the current state is unhealthy because the givenwarnable is set.

func (*Tracker)LastNoiseDialWasRecentadded inv1.76.0

func (t *Tracker) LastNoiseDialWasRecent()bool

LastNoiseDialWasRecent notes that we're attempting to dial control via thets2021 noise protocol and reports whether the prior dial was "recent"(currently defined as 2 minutes but subject to change).

If t is nil, it reports false.

func (*Tracker)NoteDERPRegionReceivedFrameadded inv1.66.0

func (t *Tracker) NoteDERPRegionReceivedFrame(regionint)

NoteDERPRegionReceivedFrame is called to note that a frame was received fromthe given DERP region at the current time.

func (*Tracker)NoteMapRequestHeardadded inv1.66.0

func (t *Tracker) NoteMapRequestHeard(mr *tailcfg.MapRequest)

NoteMapRequestHeard notes whenever we successfully sent a map requestto control for which we received a 200 response.

func (*Tracker)OverallErroradded inv1.66.0

func (t *Tracker) OverallError()error

OverallError returns a summary of the health state.

If there are multiple problems, the error will be joined usingerrors.Join.

func (*Tracker)ReceiveFuncStatsadded inv1.66.0

func (t *Tracker) ReceiveFuncStats(whichReceiveFunc) *ReceiveFuncStats

ReceiveFuncStats returns the ReceiveFuncStats tracker for the given functype.

If t is nil, it returns nil.

func (*Tracker)RouterHealthdeprecatedadded inv1.66.0

func (t *Tracker) RouterHealth()error

RouterHealth returns the wgengine/router.Router error state.

Deprecated: Warnables should be preferred over Subsystem errors.

func (*Tracker)SetAnyInterfaceUpadded inv1.66.0

func (t *Tracker) SetAnyInterfaceUp(upbool)

SetAnyInterfaceUp sets whether any network interface is up.

func (*Tracker)SetAuthRoutineInErroradded inv1.66.0

func (t *Tracker) SetAuthRoutineInError(errerror)

SetAuthRoutineInError records the latest error encountered as a result of alogin attempt. Providing a nil error indicates successful login, or thatbeing logged in w/coordination is not currently desired.

func (*Tracker)SetAutoUpdatePrefsadded inv1.70.0

func (t *Tracker) SetAutoUpdatePrefs(checkbool, applyopt.Bool)

SetAutoUpdatePrefs sets the client auto-update preferences. The argumentsmatch the fields of ipn.AutoUpdatePrefs, but we cannot pass that structdirectly due to a circular import.

func (*Tracker)SetControlHealthadded inv1.66.0

func (t *Tracker) SetControlHealth(problems map[tailcfg.DisplayMessageID]tailcfg.DisplayMessage)

func (*Tracker)SetDERPMapadded inv1.70.0

func (t *Tracker) SetDERPMap(dm *tailcfg.DERPMap)

SetDERPMap sets the last fetched DERP map in the Tracker. The DERP map is usedto provide a region name in user-facing DERP-related warnings.

func (*Tracker)SetDERPRegionConnectedStateadded inv1.66.0

func (t *Tracker) SetDERPRegionConnectedState(regionint, connectedbool)

func (*Tracker)SetDERPRegionHealthadded inv1.66.0

func (t *Tracker) SetDERPRegionHealth(regionint, problemstring)

SetDERPRegionHealth sets or clears any problem associated with theprovided DERP region.

func (*Tracker)SetDNSHealthdeprecatedadded inv1.66.0

func (t *Tracker) SetDNSHealth(errerror)

SetDNSHealth sets the state of the net/dns.Manager

Deprecated: Warnables should be preferred over Subsystem errors.

func (*Tracker)SetDNSManagerHealthdeprecatedadded inv1.66.0

func (t *Tracker) SetDNSManagerHealth(errerror)

SetDNSManagerHealth sets the state of the Linux net/dns manager'sdiscovery of the /etc/resolv.conf situation.

Deprecated: Warnables should be preferred over Subsystem errors.

func (*Tracker)SetHealthyadded inv1.70.0

func (t *Tracker) SetHealthy(w *Warnable)

SetHealthy removes any warningState for the given Warnable.

func (*Tracker)SetIPNStateadded inv1.66.0

func (t *Tracker) SetIPNState(statestring, wantRunningbool)

state is an ipn.State.String() value: "Running", "Stopped", "NeedsLogin", etc.

func (*Tracker)SetLatestVersionadded inv1.66.0

func (t *Tracker) SetLatestVersion(v *tailcfg.ClientVersion)

SetLatestVersion records the latest version of the Tailscale client.v can be nil if unknown.

func (*Tracker)SetLocalLogConfigHealthadded inv1.66.0

func (t *Tracker) SetLocalLogConfigHealth(errerror)

SetLocalLogConfigHealth sets the error state of this client's local log configuration.

func (*Tracker)SetMagicSockDERPHomeadded inv1.66.0

func (t *Tracker) SetMagicSockDERPHome(regionint, homelessbool)

SetMagicSockDERPHome notes what magicsock's view of its home DERP is.

The homeless parameter is whether magicsock is running in DERP-disconnectedmode, without discovering and maintaining a connection to its home DERP.

func (*Tracker)SetMetricsRegistryadded inv1.76.0

func (t *Tracker) SetMetricsRegistry(reg *usermetric.Registry)

SetMetricsRegistry sets up the metrics for the Tracker. It takesa usermetric.Registry and registers the metrics there.

func (*Tracker)SetOutOfPollNetMapadded inv1.66.0

func (t *Tracker) SetOutOfPollNetMap()

SetOutOfPollNetMap records that the client is no longer inan HTTP map request long poll to the control plane.

func (*Tracker)SetRouterHealthdeprecatedadded inv1.66.0

func (t *Tracker) SetRouterHealth(errerror)

SetRouterHealth sets the state of the wgengine/router.Router.

Deprecated: Warnables should be preferred over Subsystem errors.

func (*Tracker)SetTKAHealthdeprecatedadded inv1.66.0

func (t *Tracker) SetTKAHealth(errerror)

SetTKAHealth sets the health of the tailnet key authority.

Deprecated: Warnables should be preferred over Subsystem errors.

func (*Tracker)SetTLSConnectionErroradded inv1.66.0

func (t *Tracker) SetTLSConnectionError(hoststring, errerror)

SetTLSConnectionError sets the error state for connections to a specifichost. Setting the error to nil will clear any previously-set error.

func (*Tracker)SetUDP4Unboundadded inv1.66.0

func (t *Tracker) SetUDP4Unbound(unboundbool)

SetUDP4Unbound sets whether the udp4 bind failed completely.

func (*Tracker)SetUnhealthyadded inv1.70.0

func (t *Tracker) SetUnhealthy(w *Warnable, argsArgs)

SetUnhealthy sets a warningState for the given Warnable with the provided Args, and should becalled when a Warnable becomes unhealthy, or its unhealthy status needs to be updated.SetUnhealthy takes ownership of args. The args can be nil if no additional information isneeded for the unhealthy state.

func (*Tracker)Stringsadded inv1.70.0

func (t *Tracker) Strings() []string

Strings() returns a string array containing the Text of all Warnings andControlHealth messages currently known to the Tracker. These strings can bepresented to the user, although ideally you would use the Code property oneach Warning to show a localized version of them instead. This function ishere for legacy compatibility purposes and is deprecated.

func (*Tracker)TKAHealthdeprecatedadded inv1.66.0

func (t *Tracker) TKAHealth()error

TKAHealth returns the tailnet key authority error state.

Deprecated: Warnables should be preferred over Subsystem errors.

typeUnhealthyStateadded inv1.70.0

type UnhealthyState struct {WarnableCodeWarnableCodeSeveritySeverityTitlestringTextstringBrokenSince         *time.Time            `json:",omitempty"`ArgsArgs                  `json:",omitempty"`DependsOn           []WarnableCode        `json:",omitempty"`ImpactsConnectivitybool                  `json:",omitempty"`PrimaryAction       *UnhealthyStateAction `json:",omitempty"`// ETag identifies a specific version of an UnhealthyState. If the contents// of the other fields of two UnhealthyStates are the same, the ETags will// be the same. If the contents differ, the ETags will also differ. The// implementation is not defined and the value is opaque: it might be a// hash, it might be a simple counter. Implementations should not rely on// any specific implementation detail or format of the ETag string other// than string (in)equality.ETagstring `json:",omitzero"`}

UnhealthyState contains information to be shown to the user to inform themthat aWarnable is currently unhealthy ortailcfg.DisplayMessage is beingsent from the control-plane.

typeUnhealthyStateActionadded inv1.86.0

type UnhealthyStateAction struct {URLstringLabelstring}

UnhealthyStateAction represents an action (URL and link) to be presented tothe user associated with anUnhealthyState. Analogous totailcfg.DisplayMessageAction.

typeWarnableadded inv1.34.0

type Warnable struct {// Code is a string that uniquely identifies this Warnable across the entire Tailscale backend,// and can be mapped to a user-displayable localized string.CodeWarnableCode// Title is a string that the GUI uses as title for any message involving this Warnable. The title// should be short and fit in a single line.Titlestring// Text is a function that generates an extended string that the GUI will display to the user when// this Warnable is in an unhealthy state. The function can use the Args map to provide dynamic// information to the user.Text func(argsArgs)string// Severity is the severity of the Warnable, which the GUI can use to determine how to display it.// For instance, a Warnable with SeverityHigh could trigger a modal view, while a Warnable with// SeverityLow could be displayed in a less intrusive way.// TODO(angott): turn this into a SeverityFunc, which allows the Warnable to change its severity based on// the Args of the unhappy state, just like we do in the Text function.SeveritySeverity// 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.DependsOn []*Warnable// MapDebugFlag is a MapRequest.DebugFlag that is sent to control when this Warnable is unhealthy//// Deprecated: this is only used in one case, and will be removed in a future PRMapDebugFlagstring// ImpactsConnectivity is whether this Warnable in an unhealthy state will impact the user's// ability to connect to the Internet or other nodes on the tailnet. On platforms where// the client GUI supports a tray icon, the client will display an exclamation mark// on the tray icon when ImpactsConnectivity is set to true and the Warnable is unhealthy.ImpactsConnectivitybool// TimeToVisible is the Duration that the Warnable has to be in an unhealthy state before it// should be surfaced as unhealthy to the user. This is used to prevent transient errors from being// displayed to the user.TimeToVisibletime.Duration}

A Warnable is something that we might want to warn the user about, or not. AWarnable is either in a healthy or unhealthy state. A Warnable is unhealthy ifthe Tracker knows about a WarningState affecting the Warnable.

In most cases, Warnables are components of the backend (for instance, "DNS"or "Magicsock"). Warnables are similar to the Subsystem type previously usedin this package, but they provide a unique identifying code for eachWarnable, along with more metadata that makes it easier for a GUI to displaythe Warnable in a user-friendly way.

funcRegisteradded inv1.70.0

func Register(w *Warnable) *Warnable

Register registers a new Warnable with the health package and returns it.Register panics if the Warnable was already registered, because Warnablesshould be unique across the program.

func (*Warnable)IsVisibleadded inv1.70.0

func (w *Warnable) IsVisible(ws *warningState, clockNow func()time.Time)bool

IsVisible returns whether the Warnable should be visible to the user, based on the TimeToVisiblefield of the Warnable and the BrokenSince time when the Warnable became unhealthy.

typeWarnableCodeadded inv1.70.0

type WarnableCodestring

WarnableCode is a string that distinguishes each Warnable from others. It is globally unique withinthe program.

Source Files

View all Source files

Directories

PathSynopsis
Package healthmsg contains some constants for health messages.
Package healthmsg contains some constants for health messages.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp