Skip to content

Commit 08b9681

Browse files
committed
Store agent nodes in order
1 parent 7a40bf8 commit 08b9681

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

enterprise/tailnet/coordinator.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,13 @@ func (c *haCoordinator) handleAgentUpdate(id uuid.UUID, decoder *json.Decoder) (
266266
}
267267

268268
c.mutex.Lock()
269+
oldNode := c.nodes[id]
270+
if oldNode != nil {
271+
if oldNode.AsOf.After(node.AsOf) {
272+
c.mutex.Unlock()
273+
return oldNode, nil
274+
}
275+
}
269276
c.nodes[id] = &node
270277
connectionSockets, ok := c.agentToConnectionSockets[id]
271278
if !ok {

tailnet/conn.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ func (c *Conn) sendNode() {
435435
}
436436
node := &Node{
437437
ID: c.netMap.SelfNode.ID,
438+
AsOf: c.lastStatus,
438439
Key: c.netMap.SelfNode.Key,
439440
Addresses: c.netMap.SelfNode.Addresses,
440441
AllowedIPs: c.netMap.SelfNode.AllowedIPs,

tailnet/coordinator.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ type Coordinator interface {
3737
type Node struct {
3838
// ID is used to identify the connection.
3939
ID tailcfg.NodeID `json:"id"`
40+
// AsOf is the time the node was created.
41+
AsOf time.Time `json:"as_of"`
4042
// Key is the Wireguard public key of the node.
4143
Key key.NodePublic `json:"key"`
4244
// DiscoKey is used for discovery messages over DERP to establish peer-to-peer connections.

0 commit comments

Comments
 (0)