Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf2606a7

Browse files
authored
fix: avoid converting nil node
fixes:#11276
1 parent83e1349 commitf2606a7

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

‎enterprise/tailnet/pgcoord.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ func (c *pgCoord) Node(id uuid.UUID) *agpl.Node {
185185
bestT=m.updatedAt
186186
}
187187
}
188+
ifbestN==nil {
189+
returnnil
190+
}
188191
node,err:=agpl.ProtoToNode(bestN)
189192
iferr!=nil {
190193
c.logger.Critical(c.ctx,"failed to convert node",slog.F("node",bestN),slog.Error(err))

‎enterprise/tailnet/pgcoord_test.go‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,39 @@ func TestPGCoordinator_Unhealthy(t *testing.T) {
600600
}
601601
}
602602

603+
funcTestPGCoordinator_Node_Empty(t*testing.T) {
604+
t.Parallel()
605+
606+
ctx,cancel:=context.WithTimeout(context.Background(),testutil.WaitSuperLong)
607+
defercancel()
608+
ctrl:=gomock.NewController(t)
609+
mStore:=dbmock.NewMockStore(ctrl)
610+
ps:=pubsub.NewInMemory()
611+
logger:=slogtest.Make(t,nil).Leveled(slog.LevelDebug)
612+
613+
id:=uuid.New()
614+
mStore.EXPECT().GetTailnetPeers(gomock.Any(),id).Times(1).Return(nil,nil)
615+
616+
// extra calls we don't particularly care about for this test
617+
mStore.EXPECT().UpsertTailnetCoordinator(gomock.Any(),gomock.Any()).
618+
AnyTimes().
619+
Return(database.TailnetCoordinator{},nil)
620+
mStore.EXPECT().CleanTailnetCoordinators(gomock.Any()).AnyTimes().Return(nil)
621+
mStore.EXPECT().CleanTailnetLostPeers(gomock.Any()).AnyTimes().Return(nil)
622+
mStore.EXPECT().CleanTailnetTunnels(gomock.Any()).AnyTimes().Return(nil)
623+
mStore.EXPECT().DeleteCoordinator(gomock.Any(),gomock.Any()).AnyTimes().Return(nil)
624+
625+
uut,err:=tailnet.NewPGCoord(ctx,logger,ps,mStore)
626+
require.NoError(t,err)
627+
deferfunc() {
628+
err:=uut.Close()
629+
require.NoError(t,err)
630+
}()
631+
632+
node:=uut.Node(id)
633+
require.Nil(t,node)
634+
}
635+
603636
// TestPGCoordinator_BidirectionalTunnels tests when peers create tunnels to each other. We don't
604637
// do this now, but it's schematically possible, so we should make sure it doesn't break anything.
605638
funcTestPGCoordinator_BidirectionalTunnels(t*testing.T) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp