control/controlclient,health,tailcfg: refactor control health messages (#15839)
* control/controlclient,health,tailcfg: refactor control health messages Updates tailscale/corp#27759 Signed-off-by: James Sanderson <jsanderson@tailscale.com> Signed-off-by: Paul Scott <408401+icio@users.noreply.github.com> Co-authored-by: Paul Scott <408401+icio@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
980ab4244d
commit
aa8bc23c49
@@ -6,7 +6,10 @@ package controlclient
|
||||
import (
|
||||
"cmp"
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"maps"
|
||||
"net"
|
||||
"reflect"
|
||||
@@ -828,6 +831,16 @@ func (ms *mapSession) sortedPeers() []tailcfg.NodeView {
|
||||
func (ms *mapSession) netmap() *netmap.NetworkMap {
|
||||
peerViews := ms.sortedPeers()
|
||||
|
||||
// Convert all ms.lastHealth to the new [netmap.NetworkMap.DisplayMessages].
|
||||
var msgs map[tailcfg.DisplayMessageID]tailcfg.DisplayMessage
|
||||
for _, h := range ms.lastHealth {
|
||||
mak.Set(&msgs, tailcfg.DisplayMessageID("control-health-"+strhash(h)), tailcfg.DisplayMessage{
|
||||
Title: "Coordination server reports an issue",
|
||||
Severity: tailcfg.SeverityMedium,
|
||||
Text: "The coordination server is reporting a health issue: " + h,
|
||||
})
|
||||
}
|
||||
|
||||
nm := &netmap.NetworkMap{
|
||||
NodeKey: ms.publicNodeKey,
|
||||
PrivateKey: ms.privateNodeKey,
|
||||
@@ -842,7 +855,7 @@ func (ms *mapSession) netmap() *netmap.NetworkMap {
|
||||
SSHPolicy: ms.lastSSHPolicy,
|
||||
CollectServices: ms.collectServices,
|
||||
DERPMap: ms.lastDERPMap,
|
||||
ControlHealth: ms.lastHealth,
|
||||
DisplayMessages: msgs,
|
||||
TKAEnabled: ms.lastTKAInfo != nil && !ms.lastTKAInfo.Disabled,
|
||||
}
|
||||
|
||||
@@ -868,5 +881,12 @@ func (ms *mapSession) netmap() *netmap.NetworkMap {
|
||||
if DevKnob.ForceProxyDNS() {
|
||||
nm.DNS.Proxied = true
|
||||
}
|
||||
|
||||
return nm
|
||||
}
|
||||
|
||||
func strhash(h string) string {
|
||||
s := sha256.New()
|
||||
io.WriteString(s, h)
|
||||
return hex.EncodeToString(s.Sum(nil))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user