mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 18:47:20 +01:00
seaweed-block: name the rejected entry in a startup import error
The batch import returned the bare validation error, so a bad cluster-spec node or placement seed stopped startup without saying which entry. The per-entry RegisterNode/ApplyPlan loop named it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5f4e92da5c
commit
f6588ff84c
3 files changed
+43
-2
No files matched your search
@@ -0,0 +1,41 @@
|
||||
package lifecycle
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestImportRejectionNamesTheEntry(t *testing.T) {
|
||||
nodes, err := OpenNodeInventoryStore(t.TempDir())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err = nodes.ImportNodes([]NodeRegistration{{ServerID: "good", Addr: "127.0.0.1:19001"}, {ServerID: "no-addr"}})
|
||||
if !errors.Is(err, ErrInvalidNodeRegistration) || !strings.Contains(err.Error(), "no-addr") {
|
||||
t.Fatalf("node import error = %v, want ErrInvalidNodeRegistration naming no-addr", err)
|
||||
}
|
||||
if _, ok := nodes.GetNodeSnapshot("good"); ok {
|
||||
t.Fatal("rejected node step published an entry")
|
||||
}
|
||||
if err := nodes.ImportNodes([]NodeRegistration{{ServerID: "good", Addr: "127.0.0.1:19001"}}); err != nil {
|
||||
t.Fatalf("validation rejection blocked the next import: %v", err)
|
||||
}
|
||||
|
||||
placements, err := OpenPlacementIntentStore(t.TempDir())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
valid := PlacementPlan{VolumeID: "good", DesiredRF: 1, Candidates: []PlacementCandidate{{ServerID: "node", ReplicaID: "r1", Source: PlacementSourceExistingReplica}}}
|
||||
short := PlacementPlan{VolumeID: "short", DesiredRF: 2, Candidates: valid.Candidates}
|
||||
err = placements.ImportPlans([]PlacementPlan{valid, short})
|
||||
if !errors.Is(err, ErrInsufficientPlacementCandidates) || !strings.Contains(err.Error(), "short") {
|
||||
t.Fatalf("placement import error = %v, want ErrInsufficientPlacementCandidates naming short", err)
|
||||
}
|
||||
if _, ok := placements.GetPlacementSnapshot("good"); ok {
|
||||
t.Fatal("rejected placement step published an entry")
|
||||
}
|
||||
if err := placements.ImportPlans([]PlacementPlan{valid}); err != nil {
|
||||
t.Fatalf("validation rejection blocked the next import: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -365,7 +365,7 @@ func (s *NodeInventoryStore) ImportNodes(nodes []NodeRegistration) error {
|
||||
order := make([]string, 0, len(nodes))
|
||||
for _, node := range nodes {
|
||||
if err := validateNodeRegistration(node); err != nil {
|
||||
return err
|
||||
return fmt.Errorf("lifecycle: import node %s: %w", node.ServerID, err)
|
||||
}
|
||||
reg, differs := s.registrationLocked(node)
|
||||
if !seen[reg.ServerID] {
|
||||
|
||||
@@ -285,7 +285,7 @@ func (s *PlacementIntentStore) ImportPlans(plans []PlacementPlan) error {
|
||||
for _, plan := range plans {
|
||||
intent, err := placementIntentFromPlan(plan)
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("lifecycle: import placement intent %s: %w", plan.VolumeID, err)
|
||||
}
|
||||
old, ok := s.records[intent.VolumeID]
|
||||
if !seen[intent.VolumeID] {
|
||||
|
||||
Reference in new issue
Block a user