mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 10:37:23 +01:00
test: cover foreign-holder fencing and carried lease identity
This commit is contained in:
1 parent
14aaa35e1f
commit
d2525156cc
5 files changed
+102
No files matched your search
@@ -73,3 +73,52 @@ func TestAssignmentHolderIdentityMatchingServerStillAdopts(t *testing.T) {
|
||||
t.Fatalf("matching holder did not become healthy: %+v", p)
|
||||
}
|
||||
}
|
||||
|
||||
// The old process may already have been healthy before the forced move. The
|
||||
// foreign line must withdraw that projection even though r1 is unchanged.
|
||||
func TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica(t *testing.T) {
|
||||
h, err := New(Config{MasterAddr: "127.0.0.1:1", ServerID: "old-host", VolumeID: "v1", ReplicaID: "r1", DataAddr: "127.0.0.1:19303", CtrlAddr: "127.0.0.1:19304", EnableT1Readiness: true})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = h.Close() })
|
||||
own := holderAssignment(t, "old-host")
|
||||
own.Epoch = 1
|
||||
h.applyFact(own)
|
||||
deadline := time.Now().Add(time.Second)
|
||||
for !h.view.Projection().Healthy && time.Now().Before(deadline) {
|
||||
time.Sleep(time.Millisecond)
|
||||
}
|
||||
if !h.view.Projection().Healthy {
|
||||
t.Fatal("old owner baseline not healthy")
|
||||
}
|
||||
h.applyFact(holderAssignment(t, "new-host"))
|
||||
if h.realAdpt.Projection().Epoch != 1 {
|
||||
t.Fatal("foreign epoch adopted")
|
||||
}
|
||||
if h.view.Projection().Healthy {
|
||||
t.Fatal("same-r1 foreign holder left the old frontend healthy")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAssignmentHolderIdentityRefusesCarriedEndpointMismatch(t *testing.T) {
|
||||
for _, endpoint := range []string{"data", "control"} {
|
||||
t.Run(endpoint, func(t *testing.T) {
|
||||
h, err := New(Config{MasterAddr: "127.0.0.1:1", ServerID: "new-host", VolumeID: "v1", ReplicaID: "r1", DataAddr: "127.0.0.1:19303", CtrlAddr: "127.0.0.1:19304", EnableT1Readiness: true})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = h.Close() })
|
||||
f := holderAssignment(t, "new-host")
|
||||
if endpoint == "data" {
|
||||
f.DataAddr = "127.0.0.1:9991"
|
||||
} else {
|
||||
f.CtrlAddr = "127.0.0.1:9992"
|
||||
}
|
||||
h.applyFact(f)
|
||||
if h.realAdpt.Projection().Epoch != 0 || h.LastOtherLine() == nil {
|
||||
t.Fatal("mismatched endpoint was adopted or not recorded")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package volume
|
||||
|
||||
import (
|
||||
"context"
|
||||
control "github.com/seaweedfs/seaweed-block/core/rpc/control"
|
||||
"google.golang.org/grpc"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestWorkspaceLeaseGuardCarriesHolderServerIdentity(t *testing.T) {
|
||||
seen := ""
|
||||
client := funcLeaseClient(func(_ context.Context, id *control.WorkspaceIdentity, _ ...grpc.CallOption) (*control.WorkspaceLeaseFact, error) {
|
||||
seen = id.ServerId
|
||||
return &control.WorkspaceLeaseFact{VolumeId: "v", ReplicaId: "r", Epoch: 1, ValidForNs: 1000000000}, nil
|
||||
})
|
||||
g, err := NewWorkspaceLeaseGuard(workspaceTestView{}, client, &control.WorkspaceIdentity{VolumeId: "v", ReplicaId: "r", Epoch: 1, ServerId: "node-a"}, func(context.Context) (uint64, error) { return 7, nil }, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err = g.Refresh(context.Background()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if seen != "node-a" {
|
||||
t.Fatalf("master saw holder server %q, want node-a", seen)
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ Seaweed Block release notes use narrow product claims. Each alpha version names
|
||||
what a user or reviewer can actually run, what QA evidence backs it, and what
|
||||
is still outside the supported boundary.
|
||||
|
||||
- [Holder identity and pre-release upgrades](holder-identity.md)
|
||||
- [v0.1 Alpha — Kubernetes Block Foundation](v0.1-alpha.md)
|
||||
- [v0.2 Alpha — Day-1 Activation And First Volume](v0.2-alpha.md)
|
||||
- [v0.3 Alpha — Helm Install And Observable First Volume](v0.3-alpha.md)
|
||||
@@ -93,3 +94,4 @@ The WAL multi-block record opt-in is documented separately because it is a
|
||||
backend/WAL-format optimization boundary, not a RoCE, NVMe/RDMA, or performance
|
||||
claim. It remains default-off and source-gated; a future published-image smoke
|
||||
is still required before any public release-image claim.
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# Holder identity and pre-release upgrades
|
||||
|
||||
Assignments and workspace lease requests carry the holder's server id as well
|
||||
as its replica id. Replica ids and loopback addresses may be reused on another
|
||||
host, so they do not identify the holder by themselves. A volume refuses an
|
||||
assignment with a missing or different server id, or different carried data or
|
||||
control endpoints. The master refuses a workspace lease request whose server
|
||||
id is missing or does not match the assigned holder.
|
||||
|
||||
Upgrade the master first, then the volumes, using binaries from the same
|
||||
release. A new volume connected to an older pre-release master stays not
|
||||
serving until the master is upgraded. An old volume does not gain the new
|
||||
assignment guard merely because its master has been upgraded. There is no
|
||||
compatibility flag or endpoint-based fallback.
|
||||
|
||||
This affects pre-release version mixing; it does not change the local volume
|
||||
or remote HEAD format.
|
||||
@@ -13,6 +13,13 @@ For a first, read-only try without services, see
|
||||
[first volume (read-only check)](#first-volume-read-only-check). For a write
|
||||
test, see [write test (scratch host only)](#write-test-scratch-host-only).
|
||||
|
||||
## Upgrade order
|
||||
|
||||
Upgrade `blockmaster` first, then `blockvolume`. Assignments and workspace
|
||||
lease requests require the assigned server id. A new volume against an older
|
||||
pre-release master stays not serving until the master is upgraded; an older
|
||||
volume must also be upgraded to gain the assignment guard. Do not use endpoint
|
||||
matching as a compatibility fallback. See [holder identity and upgrades](releases/holder-identity.md).
|
||||
## Get the matching files
|
||||
|
||||
The unit and settings files must come from the same commit as your
|
||||
@@ -556,3 +563,4 @@ A restore makes a new, independent volume from a snapshot. The source volume and
|
||||
- Follow it with `sw-block ops chunk restore --volume v2 --status-addr STATUS_OF_V2 --status`.
|
||||
- Until v2 is independent, a snapshot of v2 is refused (`restore_incomplete`).
|
||||
- While v2 still fetches chunks, its scheduled snapshots are skipped and counted as `restoring`. After that, until it is independent, they are refused like any snapshot and show as failed attempts with that code.
|
||||
|
||||
Reference in new issue
Block a user