Skip to content

feat: add agent acks to in-memory coordinator #12786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Apr 10, 2024
Prev Previous commit
Next Next commit
fixup! add auth to in-memory coordinator
  • Loading branch information
coadler committed Apr 10, 2024
commit 298655b4e45038e3f6ee076452812dd17bf366f5
30 changes: 18 additions & 12 deletions tailnet/configmaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func (c *configMaps) peerConfigLocked() []*tailcfg.Node {
return out
}

func (c *configMaps) setTunnelDestinaion(id uuid.UUID) {
func (c *configMaps) setTunnelDestination(id uuid.UUID) {
c.L.Lock()
defer c.L.Unlock()
lc, ok := c.peers[id]
Expand Down Expand Up @@ -542,10 +542,12 @@ func (c *configMaps) peerLostTimeout(id uuid.UUID) {
"timeout triggered for peer that is removed from the map")
return
}
if peerStatus, ok := status.Peer[lc.node.Key]; ok {
lc.lastHandshake = peerStatus.LastHandshake
if lc.node != nil {
if peerStatus, ok := status.Peer[lc.node.Key]; ok {
lc.lastHandshake = peerStatus.LastHandshake
}
logger = logger.With(slog.F("key_id", lc.node.Key.ShortString()))
}
logger = logger.With(slog.F("key_id", lc.node.Key.ShortString()))
if !lc.lost {
logger.Debug(context.Background(),
"timeout triggered for peer that is no longer lost")
Expand Down Expand Up @@ -588,7 +590,7 @@ func (c *configMaps) nodeAddresses(publicKey key.NodePublic) ([]netip.Prefix, bo
c.L.Lock()
defer c.L.Unlock()
for _, lc := range c.peers {
if lc.node.Key == publicKey {
if lc.node != nil && lc.node.Key == publicKey {
return lc.node.Addresses, true
}
}
Expand All @@ -608,12 +610,16 @@ func (c *configMaps) fillPeerDiagnostics(d *PeerDiagnostics, peerID uuid.UUID) {
if !ok {
return
}

d.ReceivedNode = lc.node
ps, ok := status.Peer[lc.node.Key]
if !ok {
return
if lc.node != nil {
ps, ok := status.Peer[lc.node.Key]
if !ok {
return
}
d.LastWireguardHandshake = ps.LastHandshake
}
d.LastWireguardHandshake = ps.LastHandshake
return
}

func (c *configMaps) peerReadyForHandshakeTimeout(peerID uuid.UUID) {
Expand All @@ -638,9 +644,9 @@ type peerLifecycle struct {
peerID uuid.UUID
// isDestination specifies if the peer is a destination, meaning we
// initiated a tunnel to the peer. When the peer is a destination, we do not
// respond to node updates with READY_FOR_HANDSHAKEs, and we wait to program
// the peer into wireguard until we receive a READY_FOR_HANDSHAKE from the
// peer or the timeout is reached.
// respond to node updates with `READY_FOR_HANDSHAKE`s, and we wait to
// program the peer into wireguard until we receive a READY_FOR_HANDSHAKE
// from the peer or the timeout is reached.
isDestination bool
// node is the tailcfg.Node for the peer. It may be nil until we receive a
// NODE update for it.
Expand Down
8 changes: 4 additions & 4 deletions tailnet/configmaps_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func TestConfigMaps_updatePeers_new_waitForHandshake_neverConfigures(t *testing.
p1Node := newTestNode(1)
p1n, err := NodeToProto(p1Node)
require.NoError(t, err)
uut.setTunnelDestinaion(p1ID)
uut.setTunnelDestination(p1ID)

// it should not send the peer to the netmap
requireNeverConfigures(ctx, t, &uut.phased)
Expand Down Expand Up @@ -250,7 +250,7 @@ func TestConfigMaps_updatePeers_new_waitForHandshake_outOfOrder(t *testing.T) {
p1Node := newTestNode(1)
p1n, err := NodeToProto(p1Node)
require.NoError(t, err)
uut.setTunnelDestinaion(p1ID)
uut.setTunnelDestination(p1ID)

go func() {
<-fEng.status
Expand Down Expand Up @@ -323,7 +323,7 @@ func TestConfigMaps_updatePeers_new_waitForHandshake(t *testing.T) {
p1Node := newTestNode(1)
p1n, err := NodeToProto(p1Node)
require.NoError(t, err)
uut.setTunnelDestinaion(p1ID)
uut.setTunnelDestination(p1ID)

go func() {
<-fEng.status
Expand Down Expand Up @@ -396,7 +396,7 @@ func TestConfigMaps_updatePeers_new_waitForHandshake_timeout(t *testing.T) {
p1Node := newTestNode(1)
p1n, err := NodeToProto(p1Node)
require.NoError(t, err)
uut.setTunnelDestinaion(p1ID)
uut.setTunnelDestination(p1ID)

go func() {
<-fEng.status
Expand Down
2 changes: 1 addition & 1 deletion tailnet/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ type Conn struct {
}

func (c *Conn) SetTunnelDestination(id uuid.UUID) {
c.configMaps.setTunnelDestinaion(id)
c.configMaps.setTunnelDestination(id)
}

func (c *Conn) GetBlockEndpoints() bool {
Expand Down