health: remove SysDNSOS, add two Warnables for read+set system DNS config (#13874)

pull/13875/head
Andrea Gottardo 1 month ago committed by GitHub
parent 72587ab03c
commit f8f53bb6d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -128,9 +128,6 @@ const (
// SysDNS is the name of the net/dns subsystem. // SysDNS is the name of the net/dns subsystem.
SysDNS = Subsystem("dns") SysDNS = Subsystem("dns")
// SysDNSOS is the name of the net/dns OSConfigurator subsystem.
SysDNSOS = Subsystem("dns-os")
// SysDNSManager is the name of the net/dns manager subsystem. // SysDNSManager is the name of the net/dns manager subsystem.
SysDNSManager = Subsystem("dns-manager") SysDNSManager = Subsystem("dns-manager")
@ -141,7 +138,7 @@ const (
var subsystemsWarnables = map[Subsystem]*Warnable{} var subsystemsWarnables = map[Subsystem]*Warnable{}
func init() { func init() {
for _, s := range []Subsystem{SysRouter, SysDNS, SysDNSOS, SysDNSManager, SysTKA} { for _, s := range []Subsystem{SysRouter, SysDNS, SysDNSManager, SysTKA} {
w := Register(&Warnable{ w := Register(&Warnable{
Code: WarnableCode(s), Code: WarnableCode(s),
Severity: SeverityMedium, Severity: SeverityMedium,
@ -510,22 +507,12 @@ func (t *Tracker) SetDNSHealth(err error) { t.setErr(SysDNS, err) }
// Deprecated: Warnables should be preferred over Subsystem errors. // Deprecated: Warnables should be preferred over Subsystem errors.
func (t *Tracker) DNSHealth() error { return t.get(SysDNS) } func (t *Tracker) DNSHealth() error { return t.get(SysDNS) }
// SetDNSOSHealth sets the state of the net/dns.OSConfigurator
//
// Deprecated: Warnables should be preferred over Subsystem errors.
func (t *Tracker) SetDNSOSHealth(err error) { t.setErr(SysDNSOS, err) }
// SetDNSManagerHealth sets the state of the Linux net/dns manager's // SetDNSManagerHealth sets the state of the Linux net/dns manager's
// discovery of the /etc/resolv.conf situation. // discovery of the /etc/resolv.conf situation.
// //
// Deprecated: Warnables should be preferred over Subsystem errors. // Deprecated: Warnables should be preferred over Subsystem errors.
func (t *Tracker) SetDNSManagerHealth(err error) { t.setErr(SysDNSManager, err) } func (t *Tracker) SetDNSManagerHealth(err error) { t.setErr(SysDNSManager, err) }
// DNSOSHealth returns the net/dns.OSConfigurator error state.
//
// Deprecated: Warnables should be preferred over Subsystem errors.
func (t *Tracker) DNSOSHealth() error { return t.get(SysDNSOS) }
// SetTKAHealth sets the health of the tailnet key authority. // SetTKAHealth sets the health of the tailnet key authority.
// //
// Deprecated: Warnables should be preferred over Subsystem errors. // Deprecated: Warnables should be preferred over Subsystem errors.

@ -8,6 +8,7 @@ import (
"context" "context"
"encoding/binary" "encoding/binary"
"errors" "errors"
"fmt"
"io" "io"
"net" "net"
"net/netip" "net/netip"
@ -156,11 +157,11 @@ func (m *Manager) setLocked(cfg Config) error {
return err return err
} }
if err := m.os.SetDNS(ocfg); err != nil { if err := m.os.SetDNS(ocfg); err != nil {
m.health.SetDNSOSHealth(err) m.health.SetUnhealthy(osConfigurationSetWarnable, health.Args{health.ArgError: err.Error()})
return err return err
} }
m.health.SetDNSOSHealth(nil) m.health.SetHealthy(osConfigurationSetWarnable)
m.config = &cfg m.config = &cfg
return nil return nil
@ -217,6 +218,26 @@ func compileHostEntries(cfg Config) (hosts []*HostEntry) {
return hosts return hosts
} }
var osConfigurationReadWarnable = health.Register(&health.Warnable{
Code: "dns-read-os-config-failed",
Title: "Failed to read system DNS configuration",
Text: func(args health.Args) string {
return fmt.Sprintf("Tailscale failed to fetch the DNS configuration of your device: %v", args[health.ArgError])
},
Severity: health.SeverityLow,
DependsOn: []*health.Warnable{health.NetworkStatusWarnable},
})
var osConfigurationSetWarnable = health.Register(&health.Warnable{
Code: "dns-set-os-config-failed",
Title: "Failed to set system DNS configuration",
Text: func(args health.Args) string {
return fmt.Sprintf("Tailscale failed to set the DNS configuration of your device: %v", args[health.ArgError])
},
Severity: health.SeverityMedium,
DependsOn: []*health.Warnable{health.NetworkStatusWarnable},
})
// compileConfig converts cfg into a quad-100 resolver configuration // compileConfig converts cfg into a quad-100 resolver configuration
// and an OS-level configuration. // and an OS-level configuration.
func (m *Manager) compileConfig(cfg Config) (rcfg resolver.Config, ocfg OSConfig, err error) { func (m *Manager) compileConfig(cfg Config) (rcfg resolver.Config, ocfg OSConfig, err error) {
@ -320,9 +341,10 @@ func (m *Manager) compileConfig(cfg Config) (rcfg resolver.Config, ocfg OSConfig
// This is currently (2022-10-13) expected on certain iOS and macOS // This is currently (2022-10-13) expected on certain iOS and macOS
// builds. // builds.
} else { } else {
m.health.SetDNSOSHealth(err) m.health.SetUnhealthy(osConfigurationReadWarnable, health.Args{health.ArgError: err.Error()})
return resolver.Config{}, OSConfig{}, err return resolver.Config{}, OSConfig{}, err
} }
m.health.SetHealthy(osConfigurationReadWarnable)
} }
if baseCfg == nil { if baseCfg == nil {

@ -163,9 +163,9 @@ func (m *resolvedManager) run(ctx context.Context) {
} }
conn.Signal(signals) conn.Signal(signals)
// Reset backoff and SetNSOSHealth after successful on reconnect. // Reset backoff and set osConfigurationSetWarnable to healthy after a successful reconnect.
bo.BackOff(ctx, nil) bo.BackOff(ctx, nil)
m.health.SetDNSOSHealth(nil) m.health.SetHealthy(osConfigurationSetWarnable)
return nil return nil
} }
@ -243,9 +243,12 @@ func (m *resolvedManager) run(ctx context.Context) {
// Set health while holding the lock, because this will // Set health while holding the lock, because this will
// graciously serialize the resync's health outcome with a // graciously serialize the resync's health outcome with a
// concurrent SetDNS call. // concurrent SetDNS call.
m.health.SetDNSOSHealth(err)
if err != nil { if err != nil {
m.logf("failed to configure systemd-resolved: %v", err) m.logf("failed to configure systemd-resolved: %v", err)
m.health.SetUnhealthy(osConfigurationSetWarnable, health.Args{health.ArgError: err.Error()})
} else {
m.health.SetHealthy(osConfigurationSetWarnable)
} }
} }
} }

Loading…
Cancel
Save