mirror of
https://github.com/juanfont/headscale.git
synced 2025-10-15 18:19:49 +00:00
Validate isOutdated against all namespaces
This commit makes isOutdated validate a nodes necessity to update against all namespaces, and not just the nodes own namespace (which made more sense before). getLastStateChange is now uses the passed namespaces as a filter, meaning that not requesting any namespace will give you the total last updated state. In addition, the sync.Map is exchanged for a variant that uses generics which allows us to remove some casting logic.
This commit is contained in:
11
machine.go
11
machine.go
@@ -9,7 +9,6 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
mapset "github.com/deckarep/golang-set/v2"
|
||||
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
|
||||
"github.com/rs/zerolog/log"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
@@ -469,10 +468,12 @@ func (h *Headscale) isOutdated(machine *Machine) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
namespaceSet := mapset.NewSet[string]()
|
||||
namespaceSet.Add(machine.Namespace.Name)
|
||||
|
||||
lastChange := h.getLastStateChange(namespaceSet.ToSlice()...)
|
||||
// Get the last update from all headscale namespaces to compare with our nodes
|
||||
// last update.
|
||||
// TODO(kradalby): Only request updates from namespaces where we can talk to nodes
|
||||
// This would mostly be for a bit of performance, and can be calculated based on
|
||||
// ACLs.
|
||||
lastChange := h.getLastStateChange()
|
||||
lastUpdate := machine.CreatedAt
|
||||
if machine.LastSuccessfulUpdate != nil {
|
||||
lastUpdate = *machine.LastSuccessfulUpdate
|
||||
|
Reference in New Issue
Block a user