tka: log a better error if there are no chain candidates

Previously if `chains` was empty, it would be passed to `computeActiveAncestor()`,
which would fail with the misleading error "multiple distinct chains".

Updates tailscale/corp#33846

Signed-off-by: Alex Chan <alexc@tailscale.com>
Change-Id: Ib93a755dbdf4127f81cbf69f3eece5a388db31c8
This commit is contained in:
Alex Chan 2025-11-10 12:03:41 +00:00 committed by Alex Chan
parent c7dbd3987e
commit 4c67df42f6

View File

@ -391,6 +391,10 @@ func computeActiveChain(storage Chonk, lastKnownOldest *AUMHash, maxIter int) (c
return chain{}, fmt.Errorf("computing candidates: %v", err) return chain{}, fmt.Errorf("computing candidates: %v", err)
} }
if len(chains) == 0 {
return chain{}, errors.New("no chain candidates in AUM storage")
}
// Find the right ancestor. // Find the right ancestor.
oldestHash, err := computeActiveAncestor(chains) oldestHash, err := computeActiveAncestor(chains)
if err != nil { if err != nil {