diff --git a/seaweed-block/core/host/master/journal_isolation_test.go b/seaweed-block/core/host/master/journal_isolation_test.go index 2a57c8c2e8..25b9207495 100644 --- a/seaweed-block/core/host/master/journal_isolation_test.go +++ b/seaweed-block/core/host/master/journal_isolation_test.go @@ -142,6 +142,25 @@ func TestColocatedNodeIsAlarmedButAcceptedByDefault(t *testing.T) { } } +// A node that moves its durable root off the authority store's file system +// leaves the co-located set on its next heartbeat: strict isolation accepts +// it again and no longer refuses new work on it. +func TestColocatedNodeLeavesTheSetWhenItMovesOff(t *testing.T) { + r := newIsolationRig(t, true, t.TempDir(), t.TempDir()) + if err := r.heartbeat("node-a", masterStore); status.Code(err) != codes.FailedPrecondition { + t.Fatalf("strict heartbeat of a co-located new node: %v, want FailedPrecondition", err) + } + if !r.m.colocatedTargetRefused("node-a") || r.m.WorkspaceLeaseStatus().ColocatedNodes != 1 { + t.Fatal("co-located node not recorded") + } + if err := r.heartbeat("node-a", storeident.Identity{MachineID: "machine-1", Dev: 2050}); err != nil { + t.Fatalf("strict refused the node after it moved off the store's file system: %v", err) + } + if r.m.colocatedTargetRefused("node-a") || r.m.WorkspaceLeaseStatus().ColocatedNodes != 0 { + t.Fatal("node still counted as co-located after it moved off") + } +} + // Strict: a co-located node that serves no volume is refused // (FailedPrecondition) and still alarmed; a node elsewhere is accepted. func TestStrictRefusesColocatedNodeWithoutVolumes(t *testing.T) { diff --git a/seaweed-block/core/host/master/workspace_service_test.go b/seaweed-block/core/host/master/workspace_service_test.go index 11e11a9ccd..7efb8e8986 100644 --- a/seaweed-block/core/host/master/workspace_service_test.go +++ b/seaweed-block/core/host/master/workspace_service_test.go @@ -162,4 +162,17 @@ func TestWorkspaceRPCCleanMovePreservesReplicaIdentity(t *testing.T) { if state := restarted.Publisher().WorkspaceState("vol-a"); state == nil || len(state.Moves) != 1 || !state.Moves[0].Issued { t.Fatal(state) } + // Journal isolation reads "serves" from durable state: the issued move's + // target serves vol-a through its authority line alone (the placement + // still names the old node), also on a restarted master. + if p, ok := restarted.Lifecycle().Placements.GetPlacement("vol-a"); ok { + for _, slot := range p.Slots { + if slot.ServerID == "node-b" { + t.Fatalf("placement already names the move target: %+v", p) + } + } + } + if !restarted.nodeServesVolumes("node-b") { + t.Fatal("the issued move's target does not count as serving vol-a") + } }