mirror of
https://github.com/juanfont/headscale.git
synced 2026-11-24 06:06:29 +09:00
state: report unindexed node key instead of panicking
A missing key yields the zero NodeView; its ID() panicked inside a reader goroutine and took down the test binary instead of failing with a diagnostic.
This commit is contained in:
1 parent
85bda7c2c9
commit
541ef40c87
1 file changed
+7
-2
@@ -2449,9 +2449,14 @@ func nodeKeyIndexMismatch(snap *Snapshot) string {
|
||||
}
|
||||
|
||||
for _, nv := range snap.allNodes {
|
||||
// A missing key yields the zero view, whose ID() panics.
|
||||
got, ok := snap.nodesByNodeKey[nv.NodeKey()]
|
||||
if !ok || got.ID() != nv.ID() {
|
||||
return fmt.Sprintf("node %d: key indexed=%t id=%d", nv.ID(), ok, got.ID())
|
||||
if !ok {
|
||||
return fmt.Sprintf("node %d: key not indexed", nv.ID())
|
||||
}
|
||||
|
||||
if got.ID() != nv.ID() {
|
||||
return fmt.Sprintf("node %d: key indexed to node %d", nv.ID(), got.ID())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user