Skip to content

Commit

Permalink
clean up logging, populate online for change
Browse files Browse the repository at this point in the history
Signed-off-by: Kristoffer Dalby <[email protected]>
  • Loading branch information
kradalby committed Nov 27, 2023
1 parent 57f3dfc commit efe6d5e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 21 deletions.
11 changes: 0 additions & 11 deletions hscontrol/mapper/tail.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/juanfont/headscale/hscontrol/policy"
"github.com/juanfont/headscale/hscontrol/types"
"github.com/juanfont/headscale/hscontrol/util"
"github.com/rs/zerolog/log"
"github.com/samber/lo"
"tailscale.com/tailcfg"
)
Expand Down Expand Up @@ -91,16 +90,6 @@ func tailNode(
return nil, fmt.Errorf("tailNode, failed to create FQDN: %s", err)
}

if node.IsOnline != nil {
if *node.IsOnline {
log.Trace().Msgf("NODE IS ONLINE %s", node.Hostname)
} else {
log.Trace().Msgf("NODE IS NOT ONLINE %s", node.Hostname)
}
} else {
log.Trace().Msgf("NODE IS ONLINE IS NIL %s", node.Hostname)
}

tags, _ := pol.TagsOfNode(node)
tags = lo.Uniq(append(tags, node.ForcedTags...))

Expand Down
18 changes: 8 additions & 10 deletions hscontrol/poll.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,27 +348,25 @@ func (h *Headscale) handlePoll(
case types.StateFullUpdate:
logInfo("Sending Full MapResponse")

log.Trace().Msgf("NODE FULLMAP BEGIN %s", node.Hostname)

// TODO(kradalby): We need to update online status in this case
data, err = mapp.FullMapResponse(mapRequest, node, h.ACLPolicy)
log.Trace().Msgf("NODE FULLMAP END %s", node.Hostname)
case types.StatePeerChanged:
logInfo("Sending Changed MapResponse")

log.Trace().Msgf("NODE CHANGEDMAP BEGIN %s", node.Hostname)
for _, node := range update.ChangeNodes {
isOnline := h.nodeNotifier.IsConnected(node.MachineKey)
node.IsOnline = &isOnline
}

// TODO(kradalby): We need to update online status in this case
data, err = mapp.PeerChangedResponse(mapRequest, node, update.ChangeNodes, h.ACLPolicy)
log.Trace().Msgf("NODE CHANGEDMAP END %s", node.Hostname)
case types.StatePeerChangedNoPolicy:
logInfo("Sending PeerChangedWithoutACL MapResponse")

log.Trace().Msgf("NODE PATCHMAP BEGIN %s", node.Hostname)
for _, node := range update.ChangeNodes {
isOnline := h.nodeNotifier.IsConnected(node.MachineKey)
node.IsOnline = &isOnline
}

// TODO(kradalby): We need to update online status in this case
data, err = mapp.PeerChangedWithoutACLResponse(mapRequest, node, update.ChangeNodes, h.ACLPolicy)
log.Trace().Msgf("NODE PATCHMAP BEGIN %s", node.Hostname)
case types.StatePeerChangedPatch:
logInfo("Sending PeerChangedPatch MapResponse")
data, err = mapp.PeerChangedPatchResponse(mapRequest, node, update.ChangePatches, h.ACLPolicy)
Expand Down

0 comments on commit efe6d5e

Please sign in to comment.