health: begin work to use structured health warnings instead of strings, pipe changes into ipn.Notify (#12406)
Updates tailscale/tailscale#4136
This PR is the first round of work to move from encoding health warnings as strings and use structured data instead. The current health package revolves around the idea of Subsystems. Each subsystem can have (or not have) a Go error associated with it. The overall health of the backend is given by the concatenation of all these errors.
This PR polishes the concept of Warnable introduced by @bradfitz a few weeks ago. Each Warnable is a component of the backend (for instance, things like 'dns' or 'magicsock' are Warnables). Each Warnable has a unique identifying code. A Warnable is an entity we can warn the user about, by setting (or unsetting) a WarningState for it. Warnables have:
- an identifying Code, so that the GUI can track them as their WarningStates come and go
- a Title, which the GUIs can use to tell the user what component of the backend is broken
- a Text, which is a function that is called with a set of Args to generate a more detailed error message to explain the unhappy state
Additionally, this PR also begins to send Warnables and their WarningStates through LocalAPI to the clients, using ipn.Notify messages. An ipn.Notify is only issued when a warning is added or removed from the Tracker.
In a next PR, we'll get rid of subsystems entirely, and we'll start using structured warnings for all errors affecting the backend functionality.
Signed-off-by: Andrea Gottardo <andrea@gottardo.me>
2024-06-14 18:53:56 +00:00
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
|
|
|
|
package health
|
|
|
|
|
|
|
|
// Arg is a type for the key to be used in the Args of a Warnable.
|
|
|
|
type Arg string
|
|
|
|
|
|
|
|
const (
|
|
|
|
// ArgAvailableVersion provides an update notification Warnable with the available version of the Tailscale client.
|
|
|
|
ArgAvailableVersion Arg = "available-version"
|
|
|
|
|
|
|
|
// ArgCurrentVersion provides an update notification Warnable with the current version of the Tailscale client.
|
|
|
|
ArgCurrentVersion Arg = "current-version"
|
|
|
|
|
|
|
|
// ArgDuration provides a Warnable with how long the Warnable has been in an unhealthy state.
|
|
|
|
ArgDuration Arg = "duration"
|
|
|
|
|
|
|
|
// ArgError provides a Warnable with the underlying error behind an unhealthy state.
|
|
|
|
ArgError Arg = "error"
|
|
|
|
|
|
|
|
// ArgMagicsockFunctionName provides a Warnable with the name of the Magicsock function that caused the unhealthy state.
|
|
|
|
ArgMagicsockFunctionName Arg = "magicsock-function-name"
|
|
|
|
|
2024-06-18 23:03:17 +00:00
|
|
|
// ArgDERPRegionID provides a Warnable with the ID of a DERP server involved in the unhealthy state.
|
|
|
|
ArgDERPRegionID Arg = "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".
|
|
|
|
ArgDERPRegionName Arg = "derp-region-name"
|
health: begin work to use structured health warnings instead of strings, pipe changes into ipn.Notify (#12406)
Updates tailscale/tailscale#4136
This PR is the first round of work to move from encoding health warnings as strings and use structured data instead. The current health package revolves around the idea of Subsystems. Each subsystem can have (or not have) a Go error associated with it. The overall health of the backend is given by the concatenation of all these errors.
This PR polishes the concept of Warnable introduced by @bradfitz a few weeks ago. Each Warnable is a component of the backend (for instance, things like 'dns' or 'magicsock' are Warnables). Each Warnable has a unique identifying code. A Warnable is an entity we can warn the user about, by setting (or unsetting) a WarningState for it. Warnables have:
- an identifying Code, so that the GUI can track them as their WarningStates come and go
- a Title, which the GUIs can use to tell the user what component of the backend is broken
- a Text, which is a function that is called with a set of Args to generate a more detailed error message to explain the unhappy state
Additionally, this PR also begins to send Warnables and their WarningStates through LocalAPI to the clients, using ipn.Notify messages. An ipn.Notify is only issued when a warning is added or removed from the Tracker.
In a next PR, we'll get rid of subsystems entirely, and we'll start using structured warnings for all errors affecting the backend functionality.
Signed-off-by: Andrea Gottardo <andrea@gottardo.me>
2024-06-14 18:53:56 +00:00
|
|
|
|
|
|
|
// ArgServerName provides a Warnable with the hostname of a server involved in the unhealthy state.
|
|
|
|
ArgServerName Arg = "server-name"
|
2024-07-29 17:48:46 +00:00
|
|
|
|
|
|
|
// 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.
|
|
|
|
ArgDNSServers Arg = "dns-servers"
|
health: begin work to use structured health warnings instead of strings, pipe changes into ipn.Notify (#12406)
Updates tailscale/tailscale#4136
This PR is the first round of work to move from encoding health warnings as strings and use structured data instead. The current health package revolves around the idea of Subsystems. Each subsystem can have (or not have) a Go error associated with it. The overall health of the backend is given by the concatenation of all these errors.
This PR polishes the concept of Warnable introduced by @bradfitz a few weeks ago. Each Warnable is a component of the backend (for instance, things like 'dns' or 'magicsock' are Warnables). Each Warnable has a unique identifying code. A Warnable is an entity we can warn the user about, by setting (or unsetting) a WarningState for it. Warnables have:
- an identifying Code, so that the GUI can track them as their WarningStates come and go
- a Title, which the GUIs can use to tell the user what component of the backend is broken
- a Text, which is a function that is called with a set of Args to generate a more detailed error message to explain the unhappy state
Additionally, this PR also begins to send Warnables and their WarningStates through LocalAPI to the clients, using ipn.Notify messages. An ipn.Notify is only issued when a warning is added or removed from the Tracker.
In a next PR, we'll get rid of subsystems entirely, and we'll start using structured warnings for all errors affecting the backend functionality.
Signed-off-by: Andrea Gottardo <andrea@gottardo.me>
2024-06-14 18:53:56 +00:00
|
|
|
)
|