master: read-only format level, a new cluster starts at level 1

LifecycleService.FormatLevel answers the cluster's format level (a
viewer's read; sw-block cluster format-level). A master that finds no
prior authority state writes the level-1 envelope before it serves;
existing state keeps its level, so only a cluster holding v1.0 data
needs the finalize. Above level 0 a node that has not reported its read
level is refused new work typed and retryable (AWAITING_FIRST_REPORT),
and the cluster status shows it awaiting report. The master tests' fake
hosts report reads_level 1 as a v1.1 host does; the FormatGate upgrade
tests start from a store in v1.0.x's form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
pingqiuandClaude Opus 5.5 committed 2026-12-02 02:07:57 -08:00
1 parent a290c1e023
commit 36d797cf01
39 files changed
+611 -121

No files matched your search

+40 -2
View File
@@ -25,15 +25,17 @@ var clusterLifecycleDial = func(addr string) (control.LifecycleServiceClient, fu
return control.NewLifecycleServiceClient(conn), conn.Close, nil
}
// runCluster is "sw-block cluster finalize-format|retire-host".
// runCluster is "sw-block cluster finalize-format|format-level|retire-host".
func runCluster(args []string, stdout, stderr io.Writer) int {
if len(args) == 0 {
fmt.Fprintln(stderr, "sw-block: expected subcommand cluster finalize-format|retire-host")
fmt.Fprintln(stderr, "sw-block: expected subcommand cluster finalize-format|format-level|retire-host")
return ops.VolumeStatusExitInvalid
}
switch args[0] {
case "finalize-format":
return runClusterFinalizeFormat(args[1:], stdout, stderr)
case "format-level":
return runClusterFormatLevel(args[1:], stdout, stderr)
case "retire-host":
return runClusterRetireHost(args[1:], stdout, stderr)
}
@@ -41,6 +43,42 @@ func runCluster(args []string, stdout, stderr io.Writer) int {
return ops.VolumeStatusExitInvalid
}
// clusterFormatLevel reads the cluster's format level from the master.
func clusterFormatLevel(ctx context.Context, master string) (uint32, error) {
c, closeFn, err := clusterLifecycleDial(master)
if err != nil {
return 0, err
}
defer closeFn()
resp, err := c.FormatLevel(ctx, &control.FormatLevelRequest{})
if err != nil {
return 0, err
}
return resp.GetFormatLevel(), nil
}
// runClusterFormatLevel prints the cluster's format level: 0 (v1.0
// semantics; an upgraded cluster before its finalize) or 1.
func runClusterFormatLevel(args []string, stdout, stderr io.Writer) int {
fs := flag.NewFlagSet("sw-block cluster format-level", flag.ContinueOnError)
fs.SetOutput(stderr)
master := fs.String("master", "", "blockmaster gRPC address (required)")
timeout := fs.Duration("timeout", 30*time.Second, "how long to wait for the master's answer")
if err := fs.Parse(args); err != nil || fs.NArg() != 0 || *master == "" {
fmt.Fprintln(stderr, "usage: sw-block cluster format-level --master host:port [--timeout 30s]")
return ops.VolumeStatusExitInvalid
}
ctx, cancel := context.WithTimeout(context.Background(), *timeout)
defer cancel()
level, err := clusterFormatLevel(ctx, *master)
if err != nil {
fmt.Fprintln(stderr, "sw-block: cluster format-level:", err)
return ops.VolumeStatusExitUnhealthy
}
fmt.Fprintf(stdout, "format level %d\n", level)
return 0
}
// runClusterFinalizeFormat raises the cluster's format level to 1. Going
// back to v1.0.x works only before it: afterwards a v1.0.x master or holder
// refuses the store (an expected refusal, not damage). The master refuses
@@ -3,6 +3,7 @@ package main
import (
"bytes"
"context"
"fmt"
"strings"
"testing"
@@ -16,6 +17,11 @@ type fakeClusterMaster struct {
control.LifecycleServiceClient
finalize func(*control.FinalizeFormatRequest) (*control.FinalizeFormatResponse, error)
retire func(*control.RetireHostRequest) (*control.RetireHostResponse, error)
level func() (*control.FormatLevelResponse, error)
}
func (f *fakeClusterMaster) FormatLevel(context.Context, *control.FormatLevelRequest, ...grpc.CallOption) (*control.FormatLevelResponse, error) {
return f.level()
}
func (f *fakeClusterMaster) FinalizeFormat(_ context.Context, r *control.FinalizeFormatRequest, _ ...grpc.CallOption) (*control.FinalizeFormatResponse, error) {
@@ -92,3 +98,31 @@ func TestClusterRetireHost(t *testing.T) {
t.Fatalf("retire without --confirm: exit %d, want 2", code)
}
}
// format-level prints the master's level (0 or 1) and exits 0; a master that
// cannot answer exits nonzero (a client decides from the level only when it
// has one; the snapshot CLI then runs at 0).
func TestClusterFormatLevel(t *testing.T) {
for _, want := range []uint32{0, 1} {
withClusterMaster(t, &fakeClusterMaster{level: func() (*control.FormatLevelResponse, error) {
return &control.FormatLevelResponse{FormatLevel: want}, nil
}})
var out, errOut bytes.Buffer
if code := run([]string{"cluster", "format-level", "--master", "m:1"}, &out, &errOut); code != 0 || strings.TrimSpace(out.String()) != fmt.Sprintf("format level %d", want) {
t.Fatalf("level %d: exit %d, stdout %q, stderr %q", want, code, out.String(), errOut.String())
}
if got, err := clusterFormatLevel(context.Background(), "m:1"); err != nil || got != want {
t.Fatalf("clusterFormatLevel: %d %v, want %d", got, err, want)
}
}
withClusterMaster(t, &fakeClusterMaster{level: func() (*control.FormatLevelResponse, error) {
return nil, status.Error(codes.Unavailable, "master down")
}})
var out, errOut bytes.Buffer
if code := run([]string{"cluster", "format-level", "--master", "m:1"}, &out, &errOut); code == 0 {
t.Fatalf("an unreachable master: exit 0, stdout %q", out.String())
}
if code := run([]string{"cluster", "format-level"}, &out, &errOut); code == 0 {
t.Fatal("format-level without --master: exit 0")
}
}
@@ -96,7 +96,7 @@ func (m authMaster) lineOnNodeA(t *testing.T, ctx context.Context) authority.Aut
if _, err := control.NewWorkspaceServiceClient(alice).PlaceWorkspace(ctx, &control.WorkspacePlacement{VolumeId: "v", ServerId: "node-a", ReplicaId: "r1"}); err != nil {
t.Fatal("operator PlaceWorkspace:", err)
}
if _, err := control.NewObservationServiceClient(nodeA).ReportHeartbeat(ctx, &control.HeartbeatReport{ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
if _, err := control.NewObservationServiceClient(nodeA).ReportHeartbeat(ctx, &control.HeartbeatReport{ReadsLevel: 1, ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
Slots: []*control.HeartbeatSlot{{VolumeId: "v", ReplicaId: "r1", DataAddr: b.DataAddr, CtrlAddr: b.CtrlAddr}}}); err != nil {
t.Fatal("node-a heartbeat:", err)
}
@@ -141,7 +141,7 @@ func TestNodeActsOnlyForItsOwnServerID(t *testing.T) {
defer cancel()
line := m.lineOnNodeA(t, ctx)
nodeB := m.dial("node-b")
_, err := control.NewObservationServiceClient(nodeB).ReportHeartbeat(ctx, &control.HeartbeatReport{ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
_, err := control.NewObservationServiceClient(nodeB).ReportHeartbeat(ctx, &control.HeartbeatReport{ReadsLevel: 1, ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
Slots: []*control.HeartbeatSlot{{VolumeId: "v", ReplicaId: "r1", DataAddr: "127.0.0.1:10000", CtrlAddr: "127.0.0.1:10001"}}})
if status.Code(err) != codes.PermissionDenied {
t.Fatalf("node-b's heartbeat naming node-a: %v; want PERMISSION_DENIED", err)
+1
View File
@@ -20,6 +20,7 @@ var masterRules = map[string]auth.Rule{
control.LifecycleService_ReserveVolumeDeletion_FullMethodName: {Min: auth.RoleAdmin, Strict: true},
control.LifecycleService_CheckVolumeNoLiveLease_FullMethodName: {Min: auth.RoleViewer},
control.LifecycleService_FinalizeFormat_FullMethodName: {Min: auth.RoleAdmin, Strict: true},
control.LifecycleService_FormatLevel_FullMethodName: {Min: auth.RoleViewer},
control.LifecycleService_RetireHost_FullMethodName: {Min: auth.RoleAdmin, Strict: true},
control.ObservationService_ReportHeartbeat_FullMethodName: {Node: true},
+2 -2
View File
@@ -42,8 +42,8 @@ func TestMasterAuthorizationTableCoversEveryMethod(t *testing.T) {
}
// SubscribeProbeRounds and AnswerProbe (the promotion probe round) are
// node-only, each for the caller's own server id.
if len(registered) != 31 {
t.Fatalf("%d registered methods; the table was written for 31 (FinalizeFormat and RetireHost added, admin and strict): review the new ones", len(registered))
if len(registered) != 32 {
t.Fatalf("%d registered methods; the table was written for 32 (FinalizeFormat and RetireHost added, admin and strict; FormatLevel added, a viewer's read): review the new ones", len(registered))
}
}
@@ -28,7 +28,7 @@ func TestRecordedDynamicIntentRetriesAfterRestartWithTheLoopOff(t *testing.T) {
name = "authority-issued"
}
t.Run(name, func(t *testing.T) {
cfg := Config{Listen: "127.0.0.1:0", AuthorityStoreDir: t.TempDir(), LifecycleStoreDir: t.TempDir(), WorkspaceRPC: true, LifecycleProductLoop: true, LayoutCreateVolume: testLayoutCreateVolume,
cfg := Config{Listen: "127.0.0.1:0", AuthorityStoreDir: upgradedStoreDir(t) /* level 0: placement before any heartbeat */, LifecycleStoreDir: t.TempDir(), WorkspaceRPC: true, LifecycleProductLoop: true, LayoutCreateVolume: testLayoutCreateVolume,
WorkspaceHeadReader: func(context.Context, string) (authority.WorkspaceHead, error) { return authority.WorkspaceHead{}, nil }}
start := func() (*Host, *grpc.ClientConn) {
t.Helper()
@@ -65,7 +65,7 @@ func TestRecordedDynamicIntentRetriesAfterRestartWithTheLoopOff(t *testing.T) {
t.Fatal(err)
}
if issued {
if _, err := control.NewObservationServiceClient(conn).ReportHeartbeat(ctx, &control.HeartbeatReport{ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
if _, err := control.NewObservationServiceClient(conn).ReportHeartbeat(ctx, &control.HeartbeatReport{ReadsLevel: 1, ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
Slots: []*control.HeartbeatSlot{{VolumeId: "dynamic", ReplicaId: "r1", DataAddr: binding.DataAddr, CtrlAddr: binding.CtrlAddr, Incarnation: "process-a"}}}); err != nil {
t.Fatal(err)
}
@@ -219,7 +219,7 @@ func assignmentProducerCases() []struct {
func assignmentProducerMaster(t *testing.T, loop bool, static string, create func(context.Context, lifecycle.VolumeSpec) error) (*Host, *grpc.ClientConn) {
t.Helper()
cfg := Config{Listen: "127.0.0.1:0", AuthorityStoreDir: t.TempDir(), LifecycleStoreDir: t.TempDir(), WorkspaceRPC: true, LifecycleProductLoop: loop, LayoutCreateVolume: create,
cfg := Config{Listen: "127.0.0.1:0", AuthorityStoreDir: upgradedStoreDir(t) /* level 0: placement before any heartbeat */, LifecycleStoreDir: t.TempDir(), WorkspaceRPC: true, LifecycleProductLoop: loop, LayoutCreateVolume: create,
WorkspaceHeadReader: func(context.Context, string) (authority.WorkspaceHead, error) { return authority.WorkspaceHead{}, nil }}
if static != "" {
cfg.Topology = authority.AcceptedTopology{Volumes: []authority.VolumeExpected{{VolumeID: static, Slots: []authority.ExpectedSlot{{ReplicaID: "r1", ServerID: "node-a"}}}}}
@@ -396,7 +396,7 @@ func installPlannedMoveGate(h *Host) {
// published at the master's record of the target, never the caller's.
func recordFailbackTargetR1(t *testing.T, h *Host) {
t.Helper()
if err := h.ObservationHost().Ingest(authority.Observation{
if err := ingestV11(h, authority.Observation{
ServerID: "node-b",
ObservedAt: time.Now().UTC(),
Server: authority.ServerFact{Reachable: true, Eligible: true},
@@ -149,6 +149,31 @@ func (h *Host) formatEligible(server string) bool {
return ok && reads >= level
}
// awaitingFirstReport reports whether server is refused new work only for
// lack of a report: the cluster's level is above 0 and server has reported
// no read level since this master started (unknown counts as old).
func (h *Host) awaitingFirstReport(server string) bool {
if h.formatLevel() == 0 {
return false
}
_, ok := h.reads.of(server, h.servedBy(server))
return !ok
}
// formatRefusal is formatTooOld as an RPC error: a node that has not reported
// yet is refused typed and retryable (AWAITING_FIRST_REPORT, naming it); a
// node that reported a lower level keeps the plain refusal.
func (h *Host) formatRefusal(prefix, server string) error {
why := h.formatTooOld(server)
if why == "" {
return nil
}
if h.awaitingFirstReport(server) {
return lifecycleclient.WithReason(status.New(codes.Unavailable, prefix+why+"; retry after its first heartbeat"), lifecycleclient.ReasonAwaitingFirstReport).Err()
}
return workspaceError(fmt.Errorf("%s%s", prefix, why))
}
// formatTooOld names why server is not format-eligible, or "" when it is.
func (h *Host) formatTooOld(server string) string {
if h.formatEligible(server) {
@@ -277,6 +302,14 @@ func (s *services) FinalizeFormat(ctx context.Context, req *control.FinalizeForm
return &control.FinalizeFormatResponse{FormatLevel: s.host.formatLevel(), Already: already}, nil
}
// FormatLevel is the cluster's format level, read-only.
func (s *services) FormatLevel(ctx context.Context, _ *control.FormatLevelRequest) (*control.FormatLevelResponse, error) {
if err := ctx.Err(); err != nil {
return nil, err
}
return &control.FormatLevelResponse{FormatLevel: s.host.formatLevel()}, nil
}
// RetireHost is the RPC of Host.RetireHost. It holds the workspace lock, as
// a placement does, so no placement onto the host lands between its check
// and the removal.
@@ -51,7 +51,7 @@ func binaryTooOld(err error) bool {
// binary_too_old, and one that reads level 1 is taken (FormatGate: Join,
// Eligible).
func TestFormatGateRefusesAnOldBinarysHeartbeatAtLevel1(t *testing.T) {
r := newIsolationRig(t, false, t.TempDir(), t.TempDir())
r := newIsolationRig(t, false, upgradedStoreDir(t), t.TempDir())
if err := r.fgHeartbeat("node-a", 0); err != nil {
t.Fatalf("level 0: an old binary's heartbeat was refused: %v", err)
}
@@ -73,7 +73,7 @@ func TestFormatGateRefusesPlacementAndMoveOntoAnOldHost(t *testing.T) {
for _, reported := range []bool{true, false} {
name := map[uint32]string{1: "level1", 0: "level0"}[level] + map[bool]string{true: "-old", false: "-silent"}[reported]
t.Run(name, func(t *testing.T) {
r := newIsolationRig(t, false, t.TempDir(), t.TempDir())
r := newIsolationRig(t, false, upgradedStoreDir(t), t.TempDir())
if reported {
if err := r.fgHeartbeat("node-b", 0); err != nil {
t.Fatal(err)
@@ -99,8 +99,12 @@ func TestFormatGateRefusesPlacementAndMoveOntoAnOldHost(t *testing.T) {
}
return
}
if status.Code(placeErr) != codes.FailedPrecondition || !strings.Contains(status.Convert(placeErr).Message(), why) {
t.Fatalf("level 1: PlaceWorkspace onto node-b: %v, want %q", placeErr, why)
wantCode := map[bool]codes.Code{true: codes.FailedPrecondition, false: codes.Unavailable}[reported] // silent: typed, retryable
if status.Code(placeErr) != wantCode || !strings.Contains(status.Convert(placeErr).Message(), why) {
t.Fatalf("level 1: PlaceWorkspace onto node-b: %v, want %s %q", placeErr, wantCode, why)
}
if !reported && reasonOf(placeErr) != lifecycleclient.ReasonAwaitingFirstReport {
t.Fatalf("level 1: a silent node's placement refusal reason %q, want %s", reasonOf(placeErr), lifecycleclient.ReasonAwaitingFirstReport)
}
if _, ok := r.m.Lifecycle().Placements.GetPlacement("fresh"); ok {
t.Fatal("a refused placement was recorded")
@@ -118,7 +122,7 @@ func TestFormatGateRefusesPlacementAndMoveOntoAnOldHost(t *testing.T) {
func TestFormatGateProductLoopPlacesOnlyOnHostsThatReadTheLevel(t *testing.T) {
for _, reads := range []uint32{0, 1} {
t.Run(map[uint32]string{0: "old", 1: "new"}[reads], func(t *testing.T) {
r := newIsolationRig(t, false, t.TempDir(), t.TempDir())
r := newIsolationRig(t, false, upgradedStoreDir(t), t.TempDir())
if _, err := r.m.Lifecycle().Nodes.RegisterNode(lifecycle.NodeRegistration{ServerID: "node-c", DataAddr: "127.0.0.1:19501", CtrlAddr: "127.0.0.1:19502",
Pools: []lifecycle.StoragePool{{PoolID: "p1", TotalBytes: 1 << 30, FreeBytes: 1 << 30, BlockSize: 4096}}}); err != nil {
t.Fatal(err)
@@ -144,7 +148,7 @@ func TestFormatGateProductLoopPlacesOnlyOnHostsThatReadTheLevel(t *testing.T) {
// Every assignment carries the cluster's format level.
func TestAssignmentFactCarriesTheFormatLevel(t *testing.T) {
r := newIsolationRig(t, false, t.TempDir(), t.TempDir())
r := newIsolationRig(t, false, upgradedStoreDir(t), t.TempDir())
svc := &services{host: r.m}
for _, level := range []uint32{0, 1} {
r.m.format.v.Store(level)
@@ -170,7 +174,7 @@ func reasonOf(err error) string {
// writes nothing. A restarted master is still at level 1 (FormatGate:
// Finalize, FinalizeKeepsHosts, OneWay).
func TestFinalizeFormatNeedsEveryRegisteredHostAndIsDurable(t *testing.T) {
authDir, lcDir := t.TempDir(), t.TempDir()
authDir, lcDir := upgradedStoreDir(t), t.TempDir()
r := newIsolationRig(t, false, authDir, lcDir)
file := filepath.Join(authDir, storeAttestationFile)
finalize := func() (*control.FinalizeFormatResponse, error) {
@@ -241,7 +245,7 @@ func TestAnAttestationEnvelopeBelowLevel1IsRefused(t *testing.T) {
// assignment, and when confirm does not repeat the server id. A host
// holding nothing is retired, and the finalize no longer counts it.
func TestRetireHostRefusesAHostThatHoldsWork(t *testing.T) {
r := newIsolationRig(t, false, t.TempDir(), t.TempDir())
r := newIsolationRig(t, false, upgradedStoreDir(t), t.TempDir())
r.createVolume(t, "held")
r.place(t, "held", "node-b")
_, err := r.lc.RetireHost(r.ctx, &control.RetireHostRequest{ServerId: "node-b", Confirm: "node-b"})
@@ -271,7 +275,7 @@ func TestRetireHostRefusesAHostThatHoldsWork(t *testing.T) {
// the master stay at 0 (the switch follows the write; FormatGateMaster
// finalize_not_atomic).
func TestAFailedFinalizeWriteLeavesLevel0(t *testing.T) {
r := newIsolationRig(t, false, t.TempDir(), t.TempDir())
r := newIsolationRig(t, false, upgradedStoreDir(t), t.TempDir())
for _, s := range []string{"node-a", "node-b"} {
if err := r.fgHeartbeat(s, 1); err != nil {
t.Fatal(err)
@@ -303,7 +307,7 @@ func (r *isolationRig) fgProcessHeartbeat(server, incarnation, vol string, reads
// and the new process's own heartbeat is taken (FormatGate: a host is a
// process).
func TestAServerReadsTheLowestLevelOfItsProcesses(t *testing.T) {
r := newIsolationRig(t, false, t.TempDir(), t.TempDir())
r := newIsolationRig(t, false, upgradedStoreDir(t), t.TempDir())
if err := r.fgHeartbeat("node-a", 1); err != nil {
t.Fatal(err)
}
@@ -359,7 +363,7 @@ func TestAServerKeepsASilentProcessThatStillHoldsItsVolume(t *testing.T) {
// finalize stays refused naming the old process, and at level 1 a placement
// onto the server stays refused by the format check.
func TestASilentOldHolderKeepsTheFinalizeAndNewWorkRefused(t *testing.T) {
r := newIsolationRig(t, false, t.TempDir(), t.TempDir())
r := newIsolationRig(t, false, upgradedStoreDir(t), t.TempDir())
now := time.Now()
r.m.reads.now = func() time.Time { return now }
if err := r.fgHeartbeat("node-a", 1); err != nil {
@@ -401,7 +405,7 @@ func TestASilentOldHolderKeepsTheFinalizeAndNewWorkRefused(t *testing.T) {
func TestThePublicationBoundaryRefusesAnAskForAnOldServer(t *testing.T) {
for _, old := range []bool{true, false} {
t.Run(map[bool]string{true: "old-process", false: "control"}[old], func(t *testing.T) {
r := newIsolationRig(t, false, t.TempDir(), t.TempDir())
r := newIsolationRig(t, false, upgradedStoreDir(t), t.TempDir())
r.createVolume(t, "v")
r.place(t, "v", "node-b")
level := uint32(1)
@@ -430,7 +434,7 @@ func TestThePublicationBoundaryRefusesAnAskForAnOldServer(t *testing.T) {
// server, after va stops being served and the report ages past the
// window.
func TestEveryVolumeOfAHeartbeatKeepsItsLevel(t *testing.T) {
r := newIsolationRig(t, false, t.TempDir(), t.TempDir())
r := newIsolationRig(t, false, upgradedStoreDir(t), t.TempDir())
now := time.Now()
r.m.reads.now = func() time.Time { return now }
if err := r.fgHeartbeat("node-a", 1); err != nil {
@@ -466,7 +470,7 @@ func TestEveryVolumeOfAHeartbeatKeepsItsLevel(t *testing.T) {
func TestAHeldAskIsRefusedAfterItsServerTurnsOutOld(t *testing.T) {
for _, downgrade := range []bool{true, false} {
t.Run(map[bool]string{true: "downgrade", false: "control"}[downgrade], func(t *testing.T) {
authDir, lcDir := t.TempDir(), t.TempDir()
authDir, lcDir := upgradedStoreDir(t), t.TempDir()
logs := &syncBuffer{}
m, err := New(Config{Listen: "127.0.0.1:0", AuthorityStoreDir: authDir, LifecycleStoreDir: lcDir, WorkspaceRPC: true, LifecycleProductLoop: true, LayoutCreateVolume: testLayoutCreateVolume,
Logger: log.New(logs, "", 0),
@@ -559,3 +563,16 @@ func TestAHeldAskIsRefusedAfterItsServerTurnsOutOld(t *testing.T) {
})
}
}
// upgradedStoreDir is an authority store directory of a cluster upgraded
// from v1.0.x: its attestation file in v1.0.x's form ({}), so the master
// starts at format level 0 and needs the finalize (a new, empty store starts
// at level 1).
func upgradedStoreDir(t *testing.T) string {
t.Helper()
dir := t.TempDir()
if err := os.WriteFile(filepath.Join(dir, storeAttestationFile), []byte("{}"), 0o644); err != nil {
t.Fatal(err)
}
return dir
}
@@ -0,0 +1,118 @@
package master
import (
"bytes"
"os"
"path/filepath"
"strings"
"testing"
"time"
"github.com/seaweedfs/seaweed-block/core/lifecycle"
control "github.com/seaweedfs/seaweed-block/core/rpc/control"
"github.com/seaweedfs/seaweed-block/core/rpc/lifecycleclient"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
// Only a master with no prior authority state starts at the current level:
// any reloaded or skipped authority record, or an attestation file in any
// form, is existing state, which keeps its own level (mutant "existing state
// initialised at 1" fails here).
func TestOnlyANewClusterStartsAtLevelOne(t *testing.T) {
for _, tc := range []struct {
name string
reloaded, skipped int
absent, want bool
}{
{"no state", 0, 0, true, true},
{"authority records", 3, 0, true, false},
{"a skipped record", 0, 1, true, false},
{"an attestation file", 0, 0, false, false},
} {
if got := newClusterAtStart(tc.reloaded, tc.skipped, tc.absent); got != tc.want {
t.Fatalf("%s: new cluster %v, want %v", tc.name, got, tc.want)
}
}
}
// A master started on an empty authority store writes the level-1 envelope
// before it serves: it reports level 1 (also through the read-only
// FormatLevel RPC) with no finalize, and a restart is still at level 1. A
// store in v1.0.x's form (an upgraded cluster) starts at level 0 and reads
// 0 through the same RPC.
func TestANewClusterStartsAtTheCurrentFormatLevel(t *testing.T) {
authDir, lcDir := t.TempDir(), t.TempDir()
r := newIsolationRig(t, false, authDir, lcDir)
if r.m.formatLevel() != 1 || r.m.Publisher().FormatLevel() != 1 {
t.Fatalf("a new cluster: level %d (publisher %d), want 1", r.m.formatLevel(), r.m.Publisher().FormatLevel())
}
resp, err := r.lc.FormatLevel(r.ctx, &control.FormatLevelRequest{})
if err != nil || resp.GetFormatLevel() != 1 {
t.Fatalf("FormatLevel on a new cluster: %v %v, want 1", resp, err)
}
b, err := os.ReadFile(filepath.Join(authDir, storeAttestationFile))
if err != nil || !bytes.Contains(b, []byte(`"format_level":1`)) {
t.Fatalf("a new cluster's attestation file: %s %v, want the level-1 envelope", b, err)
}
r.close(t)
r2 := newIsolationRig(t, false, authDir, lcDir)
if r2.m.formatLevel() != 1 {
t.Fatalf("a new cluster after a restart: level %d, want 1", r2.m.formatLevel())
}
up := newIsolationRig(t, false, upgradedStoreDir(t), t.TempDir())
resp, err = up.lc.FormatLevel(up.ctx, &control.FormatLevelRequest{})
if err != nil || resp.GetFormatLevel() != 0 || up.m.formatLevel() != 0 {
t.Fatalf("an upgraded cluster: RPC %v %v, level %d; want 0", resp, err, up.m.formatLevel())
}
}
// On a new cluster (level 1) a node that has not reported is unknown, and
// unknown counts as old: placement onto it answers the typed, retryable
// AWAITING_FIRST_REPORT naming it, and the cluster status shows it as
// awaiting report; after its first heartbeat (reads level 1) the same
// placement succeeds and the condition is gone.
func TestANewClusterPlacesOnANodeOnlyAfterItsFirstReport(t *testing.T) {
r := newIsolationRig(t, false, t.TempDir(), t.TempDir())
if r.m.formatLevel() != 1 {
t.Fatalf("setup: level %d, want 1", r.m.formatLevel())
}
r.createVolume(t, "fresh")
if _, err := r.m.Lifecycle().Nodes.RegisterNode(lifecycle.NodeRegistration{ServerID: "node-b", DataAddr: "127.0.0.1:19321", CtrlAddr: "127.0.0.1:19322"}); err != nil {
t.Fatal(err)
}
if _, err := r.ws.RegisterWorkspaceBinding(r.ctx, &control.WorkspaceBinding{VolumeId: "fresh", ServerId: "node-b", DataAddr: "127.0.0.1:19321", CtrlAddr: "127.0.0.1:19322"}); err != nil {
t.Fatal(err)
}
place := func() error {
_, err := r.ws.PlaceWorkspace(r.ctx, &control.WorkspacePlacement{VolumeId: "fresh", ServerId: "node-b", ReplicaId: "r1"})
return err
}
err := place()
if status.Code(err) != codes.Unavailable || reasonOf(err) != lifecycleclient.ReasonAwaitingFirstReport || !strings.Contains(status.Convert(err).Message(), `"node-b"`) {
t.Fatalf("placement before node-b's first report: %v (reason %q), want Unavailable AWAITING_FIRST_REPORT naming node-b", err, reasonOf(err))
}
awaiting := func() bool {
for _, n := range r.m.ObservationSnapshot(time.Now()).Nodes {
for _, c := range n.Conditions {
if n.NodeName == "node-b" && c.Reason == "awaiting_first_report" {
return true
}
}
}
return false
}
if !awaiting() {
t.Fatal("the cluster status does not show node-b as awaiting report")
}
if err := r.fgHeartbeat("node-b", 1); err != nil {
t.Fatal(err)
}
if err := place(); err != nil {
t.Fatalf("placement after node-b's first report: %v", err)
}
if awaiting() {
t.Fatal("node-b still shows awaiting report after its first heartbeat")
}
}
@@ -225,7 +225,7 @@ type controlFrontend struct {
}
func (f controlFrontend) report() *control.HeartbeatReport {
return &control.HeartbeatReport{
return &control.HeartbeatReport{ReadsLevel: 1,
ServerId: "node-a",
SentAt: timestamppb.Now(),
Slots: []*control.HeartbeatSlot{{
+14
View File
@@ -293,6 +293,20 @@ func New(cfg Config) (*Host, error) {
_ = boot.Close() // release the store lock: this master never serves
return nil, fmt.Errorf("master.New: %w", err)
}
// A new cluster starts at the current level (r2.869): with no prior
// authority state (no authority record reloaded or skipped, no
// attestation file), the master writes the level-1 envelope durably now,
// before anything is served. A crash before that write leaves the same
// empty state, so the next start makes the same choice. Existing state
// without the envelope stays level 0: only a cluster that holds v1.0 data
// needs the finalize.
if newClusterAtStart(boot.ReloadedRecords, len(boot.ReloadSkips), h.attest.absent()) {
if _, err := h.attest.finalize(); err != nil {
_ = boot.Close()
return nil, fmt.Errorf("master.New: a new cluster's format level: %w", err)
}
lg.Printf("blockmaster: new cluster: format level 1 (no prior authority state; no finalize needed)")
}
// Under the authority store's lock and before anything is served: the
// cluster's format level is the attestation file's form (the envelope
// is level 1, re-fsynced here; v1.0.x's form is level 0, where this
@@ -29,7 +29,7 @@ func (r *isolationRig) issueMove(t *testing.T, vol, requestID string) (*control.
t.Helper()
r.createVolume(t, vol)
r.place(t, vol, "node-a")
if err := r.m.ObservationHost().Ingest(authority.Observation{ServerID: "node-a", ObservedAt: time.Now().UTC(),
if err := ingestV11(r.m, authority.Observation{ServerID: "node-a", ObservedAt: time.Now().UTC(),
Slots: []authority.SlotFact{{VolumeID: vol, ReplicaID: "r1", DataAddr: "127.0.0.1:19131", CtrlAddr: "127.0.0.1:19132"}}}); err != nil {
t.Fatal(err)
}
@@ -96,7 +96,7 @@ var hbPorts = map[string][2]string{
}
func (r *isolationRig) heartbeat(server string, id storeident.Identity) error {
_, err := r.obs.ReportHeartbeat(r.ctx, &control.HeartbeatReport{ServerId: server, SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
_, err := r.obs.ReportHeartbeat(r.ctx, &control.HeartbeatReport{ReadsLevel: 1, ServerId: server, SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
MachineId: id.MachineID, DurableRootDev: id.Dev, DurableRootFsid: id.FSID,
Slots: []*control.HeartbeatSlot{{VolumeId: "hb-" + server, ReplicaId: "r-" + server, DataAddr: hbPorts[server][0], CtrlAddr: hbPorts[server][1]}}})
return err
@@ -112,7 +112,7 @@ func TestMasterLifecycleSnapshot_ExistingReplicaVerifiesFromObservationStore(t *
}); err != nil {
t.Fatalf("apply placement: %v", err)
}
if err := h.ObservationHost().Ingest(authority.Observation{
if err := ingestV11(h, authority.Observation{
ServerID: "node-a",
ObservedAt: time.Now().UTC(),
Slots: []authority.SlotFact{{
@@ -57,7 +57,7 @@ func TestLineForTheTargetsEndpointsNamesTheTargetsProcess(t *testing.T) {
{"node-d", "127.0.0.1:19401", "127.0.0.1:19402", "r2-target", now.Add(-50 * time.Millisecond)}, // fresh (window 1s), older than the source's
{"node-b", "127.0.0.1:19201", "127.0.0.1:19202", "r2-source", now},
} {
if err := h.ObservationHost().Ingest(authority.Observation{ServerID: r.server, ObservedAt: r.at,
if err := ingestV11(h, authority.Observation{ServerID: r.server, ObservedAt: r.at,
Server: authority.ServerFact{Reachable: true, Eligible: true},
Slots: []authority.SlotFact{{VolumeID: "vol-rf3", ReplicaID: "r2", DataAddr: r.data, CtrlAddr: r.ctrl,
Reachable: true, ReadyForPrimary: true, Eligible: true, Incarnation: r.incarnation}}}); err != nil {
@@ -472,7 +472,7 @@ func back(t *testing.T, h *Host, r3Missing bool) {
{ServerID: "node-b", ObservedAt: now, Server: authority.ServerFact{Reachable: true, Eligible: true}, Slots: slot("r2", "127.0.0.1:19201", "127.0.0.1:19202", false)},
{ServerID: "node-c", ObservedAt: now, Server: authority.ServerFact{Reachable: true, Eligible: true}, Slots: r3},
} {
if err := h.ObservationHost().Ingest(obs); err != nil {
if err := ingestV11(h, obs); err != nil {
t.Fatal(err)
}
}
@@ -27,6 +27,14 @@ func (h *Host) ObservationSnapshot(now time.Time) ops.ClusterEvidence {
cluster.Nodes = observationNodes(snapshot.Nodes, snapshot.Placements)
cluster.Volumes = h.observationVolumes(snapshot)
for i := range cluster.Nodes {
if h.awaitingFirstReport(cluster.Nodes[i].NodeName) {
cluster.Nodes[i].Conditions = append(cluster.Nodes[i].Conditions, ops.ObservationCondition{
Type: "FormatLevel", Status: "AwaitingReport", Reason: "awaiting_first_report", Severity: "warning",
Message: fmt.Sprintf("awaiting report: no format read level reported since the master started; no new work until its first heartbeat (cluster format level %d)", h.formatLevel()),
})
}
}
cluster.Events = h.events.list("")
cluster.Status = clusterStatus(cluster.Volumes, cluster.Nodes)
return cluster
@@ -210,7 +210,7 @@ func TestMasterObservationSnapshot_PreservesNVMeFrontendIdentityInVolumeEvidence
}); err != nil {
t.Fatalf("apply placement: %v", err)
}
if err := h.ObservationHost().Ingest(authority.Observation{
if err := ingestV11(h, authority.Observation{
ServerID: "m01",
ObservedAt: time.Now().UTC(),
Server: authority.ServerFact{Reachable: true, Eligible: true},
@@ -319,7 +319,7 @@ func ingestObservationSnapshotReplica(t *testing.T, h *Host, replica string, rea
if !ok {
t.Fatalf("unknown replica %s", replica)
}
if err := h.ObservationHost().Ingest(authority.Observation{
if err := ingestV11(h, authority.Observation{
ServerID: item.serverID,
ObservedAt: time.Now().UTC(),
Server: authority.ServerFact{Reachable: true, Eligible: true},
@@ -38,7 +38,7 @@ func ingestRF3Incarnations(t *testing.T, h *Host, r1, r2, r3 rf3Slot) {
if s.slot.skip {
continue
}
if err := h.ObservationHost().Ingest(authority.Observation{
if err := ingestV11(h, authority.Observation{
ServerID: s.server,
ObservedAt: now,
Server: authority.ServerFact{Reachable: true, Eligible: true},
@@ -465,7 +465,7 @@ func TestBootGrace_UnsupportedPathReadyStartsCountTowardFlapping(t *testing.T) {
// know: UnknownReplicaClaim, a reason outside the promotion allow-list.
func ingestUnknownClaim(t *testing.T, h *Host) {
t.Helper()
if err := h.ObservationHost().Ingest(authority.Observation{
if err := ingestV11(h, authority.Observation{
ServerID: "node-d",
ObservedAt: time.Now().UTC(),
Server: authority.ServerFact{Reachable: true, Eligible: true},
@@ -725,7 +725,7 @@ func TestG15c_ProductLoopReconcilesCreatedVolumeBeforePublishing(t *testing.T) {
}); err != nil {
t.Fatalf("register node: %v", err)
}
if err := h.ObservationHost().Ingest(authority.Observation{
if err := ingestV11(h, authority.Observation{
ServerID: "node-a",
ObservedAt: time.Now().UTC(),
Slots: []authority.SlotFact{{
@@ -770,7 +770,7 @@ func seedVerifiedExistingReplicaPlacement(t *testing.T, h *Host) {
}); err != nil {
t.Fatalf("apply placement: %v", err)
}
if err := h.ObservationHost().Ingest(authority.Observation{
if err := ingestV11(h, authority.Observation{
ServerID: "node-a",
ObservedAt: time.Now().UTC(),
Slots: []authority.SlotFact{{
@@ -875,7 +875,7 @@ func ingestRF2ObservationForServers(t *testing.T, h *Host, volumeID, r1ServerID,
}},
},
} {
if err := h.ObservationHost().Ingest(obs); err != nil {
if err := ingestV11(h, obs); err != nil {
t.Fatalf("ingest RF2 observation: %v", err)
}
}
@@ -936,7 +936,7 @@ func ingestRF3ObservationForServersWithReady(t *testing.T, h *Host, volumeID, r1
{serverID: r2ServerID, replicaID: "r2", reachable: r2Reachable, ready: r2Ready},
{serverID: r3ServerID, replicaID: "r3", reachable: r3Reachable, ready: r3Ready},
} {
if err := h.ObservationHost().Ingest(authority.Observation{
if err := ingestV11(h, authority.Observation{
ServerID: obs.serverID,
ObservedAt: now,
Server: authority.ServerFact{Reachable: obs.reachable, Eligible: obs.reachable},
@@ -998,7 +998,7 @@ func ingestRF3PartialInventoryMissingCurrent(t *testing.T, h *Host, volumeID, r1
},
}
for _, obs := range observations {
if err := h.ObservationHost().Ingest(obs); err != nil {
if err := ingestV11(h, obs); err != nil {
t.Fatalf("ingest RF3 partial inventory observation: %v", err)
}
}
@@ -146,7 +146,7 @@ func TestFreshPromotionPeers_UsesObservationFreshness(t *testing.T) {
h := newTestMasterWithControllerConfig(t, t.TempDir(), authority.TopologyControllerConfig{ExpectedSlotsPerVolume: 3})
defer closeTestMaster(t, h)
for _, s := range []struct{ server, replica string }{{"node-a", "r1"}, {"node-b", "r2"}} {
if err := h.ObservationHost().Ingest(authority.Observation{
if err := ingestV11(h, authority.Observation{
ServerID: s.server,
ObservedAt: time.Now().UTC(),
Server: authority.ServerFact{Reachable: true, Eligible: true},
@@ -33,7 +33,7 @@ func reportRF3(t *testing.T, svc *services, r1, r2, r3 wireSlot) {
}{
{"node-a", "r1", r1}, {"node-b", "r2", r2}, {"node-c", "r3", r3},
} {
_, err := svc.ReportHeartbeat(auth.DevCall(context.Background()), &control.HeartbeatReport{
_, err := svc.ReportHeartbeat(auth.DevCall(context.Background()), &control.HeartbeatReport{ReadsLevel: 1,
ServerId: s.server, SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
Slots: []*control.HeartbeatSlot{{
VolumeId: "vol-rf3",
@@ -191,7 +191,7 @@ func TestRecoveryWatchdog_MasterLaterDegradationFollowsNormalRules(t *testing.T)
func reportR1(t *testing.T, svc *services, slot wireSlot, sentAt time.Time) {
t.Helper()
_, err := svc.ReportHeartbeat(auth.DevCall(context.Background()), &control.HeartbeatReport{
_, err := svc.ReportHeartbeat(auth.DevCall(context.Background()), &control.HeartbeatReport{ReadsLevel: 1,
ServerId: "node-a", SentAt: timestamppb.New(sentAt), Reachable: true, Eligible: true,
Slots: []*control.HeartbeatSlot{{
VolumeId: "vol-rf3", ReplicaId: "r1", DataAddr: "127.0.0.1:19101", CtrlAddr: "127.0.0.1:19102",
@@ -299,7 +299,7 @@ func TestRecoveryWatchdog_MasterDuplicateSlotHeartbeatRefused(t *testing.T) {
{slot(""), slot("recovery_timeout")}, // conflicting
{slot("recovery_timeout"), slot("recovery_timeout")}, // identical
} {
_, err := svc.ReportHeartbeat(auth.DevCall(context.Background()), &control.HeartbeatReport{
_, err := svc.ReportHeartbeat(auth.DevCall(context.Background()), &control.HeartbeatReport{ReadsLevel: 1,
ServerId: "node-a", SentAt: timestamppb.New(t0.Add(time.Duration(i+1) * time.Millisecond)),
Reachable: true, Eligible: true, Slots: slots,
})
@@ -71,7 +71,7 @@ func rf1ReissueCase(t *testing.T, first string) {
}
report := func(incarnation string) {
t.Helper()
if _, err := control.NewObservationServiceClient(conn).ReportHeartbeat(ctx, &control.HeartbeatReport{ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
if _, err := control.NewObservationServiceClient(conn).ReportHeartbeat(ctx, &control.HeartbeatReport{ReadsLevel: 1, ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
Slots: []*control.HeartbeatSlot{{VolumeId: "rt", ReplicaId: "r1", DataAddr: b.DataAddr, CtrlAddr: b.CtrlAddr, Incarnation: incarnation}}}); err != nil {
t.Fatal(err)
}
@@ -158,7 +158,7 @@ func TestRF1RefreshDecidedBeforeACrossHostMoveIsNotApplied(t *testing.T) {
}
report := func(server string, b *control.WorkspaceBinding, incarnation string) {
t.Helper()
if _, err := control.NewObservationServiceClient(conn).ReportHeartbeat(ctx, &control.HeartbeatReport{ServerId: server, SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
if _, err := control.NewObservationServiceClient(conn).ReportHeartbeat(ctx, &control.HeartbeatReport{ReadsLevel: 1, ServerId: server, SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
Slots: []*control.HeartbeatSlot{{VolumeId: "rt", ReplicaId: "r1", DataAddr: b.DataAddr, CtrlAddr: b.CtrlAddr, Incarnation: incarnation}}}); err != nil {
t.Fatal(err)
}
@@ -54,7 +54,7 @@ func TestDisplayedPrimaryIsTheIssuedHolderNotThePlacementSlot(t *testing.T) {
Candidates: []lifecycle.PlacementCandidate{{VolumeID: "a2", ServerID: "node-b", ReplicaID: "r1", Source: lifecycle.PlacementSourceExistingReplica}}}); err != nil {
t.Fatal(err)
}
if _, err := obs.ReportHeartbeat(ctx, &control.HeartbeatReport{ServerId: "node-b", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
if _, err := obs.ReportHeartbeat(ctx, &control.HeartbeatReport{ReadsLevel: 1, ServerId: "node-b", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
Slots: []*control.HeartbeatSlot{{VolumeId: "a2", ReplicaId: "r1", DataAddr: "127.0.0.1:19301", CtrlAddr: "127.0.0.1:19302"}}}); err != nil {
t.Fatal(err)
}
@@ -93,13 +93,13 @@ func TestDisplayedPrimaryIsTheIssuedHolderNotThePlacementSlot(t *testing.T) {
}
lookup := csi.NewControlStatusLookup(control.NewEvidenceServiceClient(conn))
// only the old host reports the replica: no primary evidence from the issued holder, so no portal at all
if err := m.ObservationHost().Ingest(fact("node-b", "192.0.2.9", now.Add(time.Second))); err != nil {
if err := ingestV11(m, fact("node-b", "192.0.2.9", now.Add(time.Second))); err != nil {
t.Fatal(err)
}
if target, err := lookup.LookupPublishTarget(ctx, "a2", ""); !errors.Is(err, csi.ErrPublishTargetNotFound) {
t.Fatalf("CSI lookup with only the old host's claim: target %+v err %v, want ErrPublishTargetNotFound", target, err)
}
if err := m.ObservationHost().Ingest(fact("node-a", "127.0.0.1", now)); err != nil {
if err := ingestV11(m, fact("node-a", "127.0.0.1", now)); err != nil {
t.Fatal(err)
}
if target, err := lookup.LookupPublishTarget(ctx, "a2", ""); err != nil || !strings.Contains(fmt.Sprintf("%+v", target), "127.0.0.1:3260") || strings.Contains(fmt.Sprintf("%+v", target), "192.0.2.9") {
@@ -128,7 +128,7 @@ func TestDisplayedPrimaryIsTheIssuedHolderNotThePlacementSlot(t *testing.T) {
// heartbeatFrom sends a heartbeat for server whose slot addresses are on host.
func (r *isolationRig) heartbeatFrom(server, host string) error {
_, err := r.obs.ReportHeartbeat(r.ctx, &control.HeartbeatReport{ServerId: server, SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
_, err := r.obs.ReportHeartbeat(r.ctx, &control.HeartbeatReport{ReadsLevel: 1, ServerId: server, SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
Slots: []*control.HeartbeatSlot{{VolumeId: "hb-" + server, ReplicaId: "r-" + server, DataAddr: host + ":19611", CtrlAddr: host + ":19612"}}})
return err
}
@@ -144,7 +144,7 @@ func TestServerIDRefusedFromAHostOtherThanItsRegisteredOne(t *testing.T) {
}
// The peer is the registered host; only the advertised slot address is wrong.
obs := control.NewObservationServiceClient(r.dialFrom(t, "127.0.0.1"))
_, err := obs.ReportHeartbeat(r.ctx, &control.HeartbeatReport{ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
_, err := obs.ReportHeartbeat(r.ctx, &control.HeartbeatReport{ReadsLevel: 1, ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
Slots: []*control.HeartbeatSlot{{VolumeId: "hb-node-a", ReplicaId: "r-node-a", DataAddr: "127.0.0.2:19611", CtrlAddr: "127.0.0.2:19612"}}})
if status.Code(err) != codes.FailedPrecondition || !strings.Contains(status.Convert(err).Message(), "registered on host 127.0.0.1") {
t.Fatalf("same --server-id from a second host: %v, want FailedPrecondition naming the registered host", err)
@@ -186,7 +186,7 @@ func TestPortalAndPrimaryComeFromTheLineServerNotTheFreshestHeartbeat(t *testing
}
}
// the stale host reports the primary's replica id with a newer observation than the holder's
if err := h.ObservationHost().Ingest(authority.Observation{ServerID: stale, ObservedAt: time.Now().UTC().Add(time.Second),
if err := ingestV11(h, authority.Observation{ServerID: stale, ObservedAt: time.Now().UTC().Add(time.Second),
Server: authority.ServerFact{Reachable: true, Eligible: true},
Slots: []authority.SlotFact{{VolumeID: "pvc-a", ReplicaID: line.ReplicaID, DataAddr: "192.0.2.9:19101", CtrlAddr: "192.0.2.9:19102",
Reachable: true, ReadyForPrimary: true, Eligible: true, EvidenceScore: 99,
@@ -236,7 +236,7 @@ func TestWorkspaceHolderRefusedFromAnotherHostAtRenewAckAndStream(t *testing.T)
Candidates: []lifecycle.PlacementCandidate{{VolumeID: "w1", ServerID: "node-a", ReplicaID: "r1", Source: lifecycle.PlacementSourceExistingReplica}}}); err != nil {
t.Fatal(err)
}
if _, err := r.obs.ReportHeartbeat(r.ctx, &control.HeartbeatReport{ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
if _, err := r.obs.ReportHeartbeat(r.ctx, &control.HeartbeatReport{ReadsLevel: 1, ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
Slots: []*control.HeartbeatSlot{{VolumeId: "w1", ReplicaId: "r1", DataAddr: "127.0.0.1:19121", CtrlAddr: "127.0.0.1:19122"}}}); err != nil {
t.Fatal(err)
}
@@ -357,7 +357,7 @@ func TestCSIPublishesNoTargetWhenThePrimaryFrontendIsMissingOrRejected(t *testin
holder := h.workspaceSourceHost("pvc-a", line.ReplicaID, line.Epoch)
reprimary := func(fronts []authority.FrontendTargetFact, at time.Time) {
t.Helper()
if err := h.ObservationHost().Ingest(authority.Observation{ServerID: holder, ObservedAt: at, Server: authority.ServerFact{Reachable: true, Eligible: true},
if err := ingestV11(h, authority.Observation{ServerID: holder, ObservedAt: at, Server: authority.ServerFact{Reachable: true, Eligible: true},
Slots: []authority.SlotFact{{VolumeID: "pvc-a", ReplicaID: line.ReplicaID, DataAddr: "192.0.2.1:19101", CtrlAddr: "192.0.2.1:19102",
Reachable: true, ReadyForPrimary: true, Eligible: true, EvidenceScore: 30, Frontends: fronts}}}); err != nil {
t.Fatal(err)
@@ -419,7 +419,7 @@ func TestLiveRenewalDoesNotWaitForAHeldRegistrationWrite(t *testing.T) {
Candidates: []lifecycle.PlacementCandidate{{VolumeID: "w3", ServerID: "node-a", ReplicaID: "r1", Source: lifecycle.PlacementSourceExistingReplica}}}); err != nil {
t.Fatal(err)
}
if _, err := r.obs.ReportHeartbeat(r.ctx, &control.HeartbeatReport{ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
if _, err := r.obs.ReportHeartbeat(r.ctx, &control.HeartbeatReport{ReadsLevel: 1, ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
Slots: []*control.HeartbeatSlot{{VolumeId: "w3", ReplicaId: "r1", DataAddr: "127.0.0.1:19131", CtrlAddr: "127.0.0.1:19132"}}}); err != nil {
t.Fatal(err)
}
@@ -74,6 +74,8 @@ type storeAttestations struct {
// enveloped: the file on disk is the envelope, so the cluster's format
// level is 1 (persist then keeps that form; finalize writes it first).
enveloped bool
// onDisk: the file existed when the master loaded it.
onDisk bool
// changed[vol] is closed (and dropped) when vol's record changes.
changed map[string]chan struct{}
}
@@ -95,10 +97,26 @@ func loadStoreAttestations(dir string) (*storeAttestations, error) {
if err != nil {
return nil, fmt.Errorf("store attestations %s: %w", s.path, err)
}
s.vols, s.enveloped = vols, enveloped
s.vols, s.enveloped, s.onDisk = vols, enveloped, true
return s, nil
}
// newClusterAtStart says a starting master holds no prior authority state:
// no authority record reloaded or skipped and no attestation file. Only then
// does it start at the current format level (r2.869, FormatGate Init); any
// existing state reads its own level (an upgrade starts at 0).
func newClusterAtStart(reloaded, skipped int, attestationAbsent bool) bool {
return reloaded == 0 && skipped == 0 && attestationAbsent
}
// absent says the master found no attestation file at its start (a durable
// store, nothing attested yet in any form).
func (s *storeAttestations) absent() bool {
s.mu.Lock()
defer s.mu.Unlock()
return s.path != "" && !s.onDisk && len(s.vols) == 0
}
// decodeStoreAttestations reads either form: the envelope (a number under
// "format": this master reads format 2 only) or v1.0.x's bare map.
func decodeStoreAttestations(b []byte) (map[string]attestedStores, bool, error) {
@@ -0,0 +1,23 @@
package master
import "github.com/seaweedfs/seaweed-block/core/authority"
// ingestV11 ingests obs as a v1.1 volume host's heartbeat delivers it: the
// facts, and the reads_level (1) of each slot's process, which the
// heartbeat carries and a direct ingest skips. A new cluster starts at
// format level 1 (r2.869), where a server with no reported level counts as
// old; the tests' fake hosts are v1.1 hosts unless a test says otherwise.
func ingestV11(h *Host, obs authority.Observation) error {
server := obs.ServerID
if len(obs.Slots) == 0 {
h.reads.note(server, "", "", 1)
}
for _, s := range obs.Slots {
process := s.Incarnation
if process == "" {
process = s.DataAddr
}
h.reads.note(server, s.VolumeID, process, 1)
}
return h.ObservationHost().Ingest(obs)
}
@@ -221,8 +221,8 @@ func (s *services) PlaceWorkspace(ctx context.Context, q *control.WorkspacePlace
return nil, workspaceError(fmt.Errorf("workspace placement: node %q shares the authority store's file system (strict journal isolation)", binding.ServerID))
}
if p, ok := s.host.lifecycle.Placements.GetPlacement(q.GetVolumeId()); !(ok && identical(p)) {
if why := s.host.formatTooOld(binding.ServerID); why != "" {
return nil, workspaceError(fmt.Errorf("workspace placement: %s", why))
if err := s.host.formatRefusal("workspace placement: ", binding.ServerID); err != nil {
return nil, err
}
}
err = s.host.Publisher().RecordWorkspacePlacement(ctx, q.GetVolumeId(), func() error {
@@ -190,7 +190,7 @@ func reviewCreate(t *testing.T, c *grpc.ClientConn, ctx context.Context, vol str
func reviewHeartbeat(t *testing.T, c *grpc.ClientConn, ctx context.Context, vol, server, data, ctrl string) {
t.Helper()
if _, e := control.NewObservationServiceClient(c).ReportHeartbeat(ctx, &control.HeartbeatReport{ServerId: server, SentAt: timestamppb.Now(), Reachable: true, Eligible: true, Slots: []*control.HeartbeatSlot{{VolumeId: vol, ReplicaId: "r1", DataAddr: data, CtrlAddr: ctrl}}}); e != nil {
if _, e := control.NewObservationServiceClient(c).ReportHeartbeat(ctx, &control.HeartbeatReport{ReadsLevel: 1, ServerId: server, SentAt: timestamppb.Now(), Reachable: true, Eligible: true, Slots: []*control.HeartbeatSlot{{VolumeId: vol, ReplicaId: "r1", DataAddr: data, CtrlAddr: ctrl}}}); e != nil {
t.Fatal(e)
}
}
@@ -49,7 +49,7 @@ func TestWorkspaceBindingPlacesRF1OnChosenNode(t *testing.T) {
if _, ok := h.Publisher().VolumeAuthorityLine("chosen"); ok {
t.Fatal("placement minted authority without observation")
}
if _, err = control.NewObservationServiceClient(conn).ReportHeartbeat(ctx, &control.HeartbeatReport{ServerId: "node-chosen", SentAt: timestamppb.Now(), Reachable: true, Eligible: true, Slots: []*control.HeartbeatSlot{{VolumeId: "chosen", ReplicaId: "r1", DataAddr: b.DataAddr, CtrlAddr: b.CtrlAddr}}}); err != nil {
if _, err = control.NewObservationServiceClient(conn).ReportHeartbeat(ctx, &control.HeartbeatReport{ReadsLevel: 1, ServerId: "node-chosen", SentAt: timestamppb.Now(), Reachable: true, Eligible: true, Slots: []*control.HeartbeatSlot{{VolumeId: "chosen", ReplicaId: "r1", DataAddr: b.DataAddr, CtrlAddr: b.CtrlAddr}}}); err != nil {
t.Fatal(err)
}
if _, err = h.RunLifecycleProductTick(); err != nil {
@@ -113,7 +113,7 @@ func workspaceBindingsMove(t *testing.T, forced bool) {
if _, err = client.PlaceWorkspace(ctx, &control.WorkspacePlacement{VolumeId: vol, ServerId: "node-a", ReplicaId: "r1"}); err != nil {
t.Fatal(err)
}
if _, err = control.NewObservationServiceClient(conn).ReportHeartbeat(ctx, &control.HeartbeatReport{ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true, Slots: []*control.HeartbeatSlot{{VolumeId: vol, ReplicaId: "r1", DataAddr: src.DataAddr, CtrlAddr: src.CtrlAddr}}}); err != nil {
if _, err = control.NewObservationServiceClient(conn).ReportHeartbeat(ctx, &control.HeartbeatReport{ReadsLevel: 1, ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true, Slots: []*control.HeartbeatSlot{{VolumeId: vol, ReplicaId: "r1", DataAddr: src.DataAddr, CtrlAddr: src.CtrlAddr}}}); err != nil {
t.Fatal(err)
}
if _, err = h.RunLifecycleProductTick(); err != nil {
@@ -75,7 +75,7 @@ func TestWorkspaceExitedHolderForcedMoveThenCleanDelete(t *testing.T) {
if _, err = ws.PlaceWorkspace(ctx, &control.WorkspacePlacement{VolumeId: "vol-a", ServerId: "node-a", ReplicaId: "r1"}); err != nil {
t.Fatal(err)
}
if _, err = control.NewObservationServiceClient(conn).ReportHeartbeat(ctx, &control.HeartbeatReport{ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
if _, err = control.NewObservationServiceClient(conn).ReportHeartbeat(ctx, &control.HeartbeatReport{ReadsLevel: 1, ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
Slots: []*control.HeartbeatSlot{{VolumeId: "vol-a", ReplicaId: "r1", DataAddr: src.DataAddr, CtrlAddr: src.CtrlAddr}}}); err != nil {
t.Fatal(err)
}
@@ -88,7 +88,7 @@ func forcedMoveHost(t *testing.T, cfg Config) (*Host, func(), control.WorkspaceS
if _, err := client.PlaceWorkspace(ctx, &control.WorkspacePlacement{VolumeId: "vol-f", ServerId: "node-a", ReplicaId: "r1"}); err != nil {
t.Fatal(err)
}
if _, err := control.NewObservationServiceClient(conn).ReportHeartbeat(ctx, &control.HeartbeatReport{ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
if _, err := control.NewObservationServiceClient(conn).ReportHeartbeat(ctx, &control.HeartbeatReport{ReadsLevel: 1, ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
Slots: []*control.HeartbeatSlot{{VolumeId: "vol-f", ReplicaId: "r1", DataAddr: src.DataAddr, CtrlAddr: src.CtrlAddr}}}); err != nil {
t.Fatal(err)
}
@@ -60,7 +60,7 @@ func TestWorkspaceMoveToAnotherSlotOnTheTargetHost(t *testing.T) {
t.Fatal(err)
}
d, c := slot(base, 0)
if _, err := control.NewObservationServiceClient(conn).ReportHeartbeat(ctx, &control.HeartbeatReport{ServerId: server, SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
if _, err := control.NewObservationServiceClient(conn).ReportHeartbeat(ctx, &control.HeartbeatReport{ReadsLevel: 1, ServerId: server, SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
Slots: []*control.HeartbeatSlot{{VolumeId: vol, ReplicaId: "r1", DataAddr: d, CtrlAddr: c}}}); err != nil {
t.Fatal(err)
}
@@ -84,7 +84,7 @@ func TestWorkspaceUnclaimedGrantForcedReassignOverRPC(t *testing.T) {
if _, err = ws.PlaceWorkspace(ctx, &control.WorkspacePlacement{VolumeId: "vol-a", ServerId: "node-a", ReplicaId: "r1"}); err != nil {
t.Fatal(err)
}
if _, err = control.NewObservationServiceClient(conn).ReportHeartbeat(ctx, &control.HeartbeatReport{ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
if _, err = control.NewObservationServiceClient(conn).ReportHeartbeat(ctx, &control.HeartbeatReport{ReadsLevel: 1, ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
Slots: []*control.HeartbeatSlot{{VolumeId: "vol-a", ReplicaId: "r1", DataAddr: src.DataAddr, CtrlAddr: src.CtrlAddr}}}); err != nil {
t.Fatal(err)
}
+183 -57
View File
@@ -3961,6 +3961,92 @@ func (*ProbeAck) Descriptor() ([]byte, []int) {
return file_control_proto_rawDescGZIP(), []int{42}
}
// FormatLevel (LifecycleService) reads the cluster's format level.
type FormatLevelRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *FormatLevelRequest) Reset() {
*x = FormatLevelRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_control_proto_msgTypes[43]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *FormatLevelRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*FormatLevelRequest) ProtoMessage() {}
func (x *FormatLevelRequest) ProtoReflect() protoreflect.Message {
mi := &file_control_proto_msgTypes[43]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use FormatLevelRequest.ProtoReflect.Descriptor instead.
func (*FormatLevelRequest) Descriptor() ([]byte, []int) {
return file_control_proto_rawDescGZIP(), []int{43}
}
type FormatLevelResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
FormatLevel uint32 `protobuf:"varint,1,opt,name=format_level,json=formatLevel,proto3" json:"format_level,omitempty"`
}
func (x *FormatLevelResponse) Reset() {
*x = FormatLevelResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_control_proto_msgTypes[44]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *FormatLevelResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*FormatLevelResponse) ProtoMessage() {}
func (x *FormatLevelResponse) ProtoReflect() protoreflect.Message {
mi := &file_control_proto_msgTypes[44]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use FormatLevelResponse.ProtoReflect.Descriptor instead.
func (*FormatLevelResponse) Descriptor() ([]byte, []int) {
return file_control_proto_rawDescGZIP(), []int{44}
}
func (x *FormatLevelResponse) GetFormatLevel() uint32 {
if x != nil {
return x.FormatLevel
}
return 0
}
var File_control_proto protoreflect.FileDescriptor
var file_control_proto_rawDesc = []byte{
@@ -4642,7 +4728,12 @@ var file_control_proto_rawDesc = []byte{
0x70, 0x6c, 0x69, 0x63, 0x61, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x73, 0x45, 0x70, 0x6f, 0x63, 0x68,
0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x63, 0x6b, 0x5f, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x18,
0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x63, 0x6b, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c,
0x65, 0x22, 0x0a, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x62, 0x65, 0x41, 0x63, 0x6b, 0x2a, 0x7c, 0x0a,
0x65, 0x22, 0x0a, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x62, 0x65, 0x41, 0x63, 0x6b, 0x22, 0x14, 0x0a,
0x12, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x22, 0x38, 0x0a, 0x13, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x4c, 0x65, 0x76,
0x65, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x66, 0x6f,
0x72, 0x6d, 0x61, 0x74, 0x5f, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d,
0x52, 0x0b, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x2a, 0x7c, 0x0a,
0x0b, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x1c, 0x0a, 0x18,
0x50, 0x52, 0x49, 0x4d, 0x41, 0x52, 0x59, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x55, 0x4e, 0x53,
0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1a, 0x0a, 0x16, 0x50, 0x52,
@@ -4730,7 +4821,7 @@ var file_control_proto_rawDesc = []byte{
0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e,
0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e,
0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45,
0x76, 0x65, 0x6e, 0x74, 0x30, 0x01, 0x32, 0xbd, 0x09, 0x0a, 0x10, 0x4c, 0x69, 0x66, 0x65, 0x63,
0x76, 0x65, 0x6e, 0x74, 0x30, 0x01, 0x32, 0xa7, 0x0a, 0x0a, 0x10, 0x4c, 0x69, 0x66, 0x65, 0x63,
0x79, 0x63, 0x6c, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x6b, 0x0a, 0x0c, 0x43,
0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x12, 0x2c, 0x2e, 0x73, 0x65,
0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f,
@@ -4800,25 +4891,32 @@ var file_control_proto_rawDesc = []byte{
0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b,
0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a,
0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x65, 0x0a, 0x0a, 0x52, 0x65, 0x74, 0x69, 0x72, 0x65, 0x48, 0x6f, 0x73, 0x74, 0x12, 0x2a, 0x2e,
0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e,
0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x52, 0x65, 0x74, 0x69, 0x72, 0x65, 0x48, 0x6f,
0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x73, 0x65, 0x61, 0x77,
0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74,
0x72, 0x6f, 0x6c, 0x2e, 0x52, 0x65, 0x74, 0x69, 0x72, 0x65, 0x48, 0x6f, 0x73, 0x74, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x79, 0x0a, 0x0f, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61,
0x63, 0x6b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x66, 0x0a, 0x0f, 0x45, 0x78, 0x65,
0x63, 0x75, 0x74, 0x65, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x28, 0x2e, 0x73,
0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63,
0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64,
0x68, 0x0a, 0x0b, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x2b,
0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b,
0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x4c,
0x65, 0x76, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x73, 0x65,
0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f,
0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x4c, 0x65, 0x76, 0x65,
0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x65, 0x0a, 0x0a, 0x52, 0x65, 0x74,
0x69, 0x72, 0x65, 0x48, 0x6f, 0x73, 0x74, 0x12, 0x2a, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65,
0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f,
0x6c, 0x2e, 0x52, 0x65, 0x74, 0x69, 0x72, 0x65, 0x48, 0x6f, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e,
0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x52, 0x65,
0x74, 0x69, 0x72, 0x65, 0x48, 0x6f, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x32, 0x79, 0x0a, 0x0f, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x53, 0x65, 0x72, 0x76,
0x69, 0x63, 0x65, 0x12, 0x66, 0x0a, 0x0f, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x46, 0x61,
0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x28, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64,
0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c,
0x2e, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x42, 0x3d, 0x5a, 0x3b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f,
0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2f, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65,
0x64, 0x2d, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x72, 0x70, 0x63,
0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x3b, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x2e, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x29, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f,
0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x46, 0x61, 0x69, 0x6c, 0x62,
0x61, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x3d, 0x5a, 0x3b, 0x67,
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65,
0x64, 0x66, 0x73, 0x2f, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x2d, 0x62, 0x6c, 0x6f, 0x63,
0x6b, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72,
0x6f, 0x6c, 0x3b, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
}
var (
@@ -4834,7 +4932,7 @@ func file_control_proto_rawDescGZIP() []byte {
}
var file_control_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_control_proto_msgTypes = make([]protoimpl.MessageInfo, 43)
var file_control_proto_msgTypes = make([]protoimpl.MessageInfo, 45)
var file_control_proto_goTypes = []interface{}{
(PrimaryKind)(0), // 0: seaweedfs.block.control.PrimaryKind
(*FinalizeFormatRequest)(nil), // 1: seaweedfs.block.control.FinalizeFormatRequest
@@ -4880,34 +4978,36 @@ var file_control_proto_goTypes = []interface{}{
(*ProbeRound)(nil), // 41: seaweedfs.block.control.ProbeRound
(*ProbeAnswer)(nil), // 42: seaweedfs.block.control.ProbeAnswer
(*ProbeAck)(nil), // 43: seaweedfs.block.control.ProbeAck
(*timestamppb.Timestamp)(nil), // 44: google.protobuf.Timestamp
(*FormatLevelRequest)(nil), // 44: seaweedfs.block.control.FormatLevelRequest
(*FormatLevelResponse)(nil), // 45: seaweedfs.block.control.FormatLevelResponse
(*timestamppb.Timestamp)(nil), // 46: google.protobuf.Timestamp
}
var file_control_proto_depIdxs = []int32{
44, // 0: seaweedfs.block.control.HeartbeatReport.sent_at:type_name -> google.protobuf.Timestamp
46, // 0: seaweedfs.block.control.HeartbeatReport.sent_at:type_name -> google.protobuf.Timestamp
8, // 1: seaweedfs.block.control.HeartbeatReport.slots:type_name -> seaweedfs.block.control.HeartbeatSlot
6, // 2: seaweedfs.block.control.HeartbeatReport.store_attestation:type_name -> seaweedfs.block.control.StoreAttestation
7, // 3: seaweedfs.block.control.StoreAttestation.stores:type_name -> seaweedfs.block.control.AttestedStore
9, // 4: seaweedfs.block.control.HeartbeatSlot.frontends:type_name -> seaweedfs.block.control.FrontendTarget
44, // 5: seaweedfs.block.control.HeartbeatAck.accepted_at:type_name -> google.protobuf.Timestamp
44, // 6: seaweedfs.block.control.ClusterEventAck.accepted_at:type_name -> google.protobuf.Timestamp
46, // 5: seaweedfs.block.control.HeartbeatAck.accepted_at:type_name -> google.protobuf.Timestamp
46, // 6: seaweedfs.block.control.ClusterEventAck.accepted_at:type_name -> google.protobuf.Timestamp
13, // 7: seaweedfs.block.control.AssignmentFact.peers:type_name -> seaweedfs.block.control.ReplicaDescriptor
0, // 8: seaweedfs.block.control.AssignmentFact.primary_kind:type_name -> seaweedfs.block.control.PrimaryKind
9, // 9: seaweedfs.block.control.StatusResponse.frontends:type_name -> seaweedfs.block.control.FrontendTarget
17, // 10: seaweedfs.block.control.StatusResponse.unhealthy_replicas:type_name -> seaweedfs.block.control.ReplicaUnhealthy
44, // 11: seaweedfs.block.control.ClusterStatusResponse.captured_at:type_name -> google.protobuf.Timestamp
46, // 11: seaweedfs.block.control.ClusterStatusResponse.captured_at:type_name -> google.protobuf.Timestamp
25, // 12: seaweedfs.block.control.ClusterStatusResponse.nodes:type_name -> seaweedfs.block.control.NodeEvidence
26, // 13: seaweedfs.block.control.ClusterStatusResponse.volumes:type_name -> seaweedfs.block.control.VolumeEvidence
23, // 14: seaweedfs.block.control.ClusterStatusResponse.conditions:type_name -> seaweedfs.block.control.ObservationCondition
28, // 15: seaweedfs.block.control.ClusterStatusResponse.events:type_name -> seaweedfs.block.control.ClusterEvent
44, // 16: seaweedfs.block.control.NodeEvidence.last_heartbeat_at:type_name -> google.protobuf.Timestamp
46, // 16: seaweedfs.block.control.NodeEvidence.last_heartbeat_at:type_name -> google.protobuf.Timestamp
23, // 17: seaweedfs.block.control.NodeEvidence.conditions:type_name -> seaweedfs.block.control.ObservationCondition
27, // 18: seaweedfs.block.control.VolumeEvidence.replicas:type_name -> seaweedfs.block.control.ReplicaEvidence
23, // 19: seaweedfs.block.control.VolumeEvidence.conditions:type_name -> seaweedfs.block.control.ObservationCondition
23, // 20: seaweedfs.block.control.ReplicaEvidence.conditions:type_name -> seaweedfs.block.control.ObservationCondition
44, // 21: seaweedfs.block.control.ClusterEvent.event_time:type_name -> google.protobuf.Timestamp
44, // 22: seaweedfs.block.control.ListVolumesResponse.captured_at:type_name -> google.protobuf.Timestamp
46, // 21: seaweedfs.block.control.ClusterEvent.event_time:type_name -> google.protobuf.Timestamp
46, // 22: seaweedfs.block.control.ListVolumesResponse.captured_at:type_name -> google.protobuf.Timestamp
26, // 23: seaweedfs.block.control.ListVolumesResponse.volumes:type_name -> seaweedfs.block.control.VolumeEvidence
44, // 24: seaweedfs.block.control.VolumeTimelineResponse.captured_at:type_name -> google.protobuf.Timestamp
46, // 24: seaweedfs.block.control.VolumeTimelineResponse.captured_at:type_name -> google.protobuf.Timestamp
28, // 25: seaweedfs.block.control.VolumeTimelineResponse.events:type_name -> seaweedfs.block.control.ClusterEvent
5, // 26: seaweedfs.block.control.ObservationService.ReportHeartbeat:input_type -> seaweedfs.block.control.HeartbeatReport
42, // 27: seaweedfs.block.control.ObservationService.AnswerProbe:input_type -> seaweedfs.block.control.ProbeAnswer
@@ -4929,32 +5029,34 @@ var file_control_proto_depIdxs = []int32{
36, // 43: seaweedfs.block.control.LifecycleService.ReserveVolumeDeletion:input_type -> seaweedfs.block.control.MarkVolumeDeletingRequest
36, // 44: seaweedfs.block.control.LifecycleService.CheckVolumeNoLiveLease:input_type -> seaweedfs.block.control.MarkVolumeDeletingRequest
1, // 45: seaweedfs.block.control.LifecycleService.FinalizeFormat:input_type -> seaweedfs.block.control.FinalizeFormatRequest
3, // 46: seaweedfs.block.control.LifecycleService.RetireHost:input_type -> seaweedfs.block.control.RetireHostRequest
38, // 47: seaweedfs.block.control.FailbackService.ExecuteFailback:input_type -> seaweedfs.block.control.FailbackRequest
10, // 48: seaweedfs.block.control.ObservationService.ReportHeartbeat:output_type -> seaweedfs.block.control.HeartbeatAck
43, // 49: seaweedfs.block.control.ObservationService.AnswerProbe:output_type -> seaweedfs.block.control.ProbeAck
11, // 50: seaweedfs.block.control.ObservationService.ReportClusterEvent:output_type -> seaweedfs.block.control.ClusterEventAck
14, // 51: seaweedfs.block.control.AssignmentService.SubscribeAssignments:output_type -> seaweedfs.block.control.AssignmentFact
41, // 52: seaweedfs.block.control.AssignmentService.SubscribeProbeRounds:output_type -> seaweedfs.block.control.ProbeRound
16, // 53: seaweedfs.block.control.EvidenceService.QueryVolumeStatus:output_type -> seaweedfs.block.control.StatusResponse
24, // 54: seaweedfs.block.control.ClusterEvidenceService.GetClusterStatus:output_type -> seaweedfs.block.control.ClusterStatusResponse
29, // 55: seaweedfs.block.control.ClusterEvidenceService.ListVolumes:output_type -> seaweedfs.block.control.ListVolumesResponse
26, // 56: seaweedfs.block.control.ClusterEvidenceService.GetVolumeStatus:output_type -> seaweedfs.block.control.VolumeEvidence
30, // 57: seaweedfs.block.control.ClusterEvidenceService.GetVolumeTimeline:output_type -> seaweedfs.block.control.VolumeTimelineResponse
28, // 58: seaweedfs.block.control.ClusterEvidenceService.WatchClusterEvents:output_type -> seaweedfs.block.control.ClusterEvent
32, // 59: seaweedfs.block.control.LifecycleService.CreateVolume:output_type -> seaweedfs.block.control.CreateVolumeResponse
32, // 60: seaweedfs.block.control.LifecycleService.GetVolume:output_type -> seaweedfs.block.control.CreateVolumeResponse
35, // 61: seaweedfs.block.control.LifecycleService.DeleteVolume:output_type -> seaweedfs.block.control.DeleteVolumeResponse
37, // 62: seaweedfs.block.control.LifecycleService.MarkVolumeDeleting:output_type -> seaweedfs.block.control.MarkVolumeDeletingResponse
37, // 63: seaweedfs.block.control.LifecycleService.AbortVolumeDeleting:output_type -> seaweedfs.block.control.MarkVolumeDeletingResponse
37, // 64: seaweedfs.block.control.LifecycleService.CommitVolumeDeleting:output_type -> seaweedfs.block.control.MarkVolumeDeletingResponse
37, // 65: seaweedfs.block.control.LifecycleService.ReserveVolumeDeletion:output_type -> seaweedfs.block.control.MarkVolumeDeletingResponse
37, // 66: seaweedfs.block.control.LifecycleService.CheckVolumeNoLiveLease:output_type -> seaweedfs.block.control.MarkVolumeDeletingResponse
2, // 67: seaweedfs.block.control.LifecycleService.FinalizeFormat:output_type -> seaweedfs.block.control.FinalizeFormatResponse
4, // 68: seaweedfs.block.control.LifecycleService.RetireHost:output_type -> seaweedfs.block.control.RetireHostResponse
39, // 69: seaweedfs.block.control.FailbackService.ExecuteFailback:output_type -> seaweedfs.block.control.FailbackResponse
48, // [48:70] is the sub-list for method output_type
26, // [26:48] is the sub-list for method input_type
44, // 46: seaweedfs.block.control.LifecycleService.FormatLevel:input_type -> seaweedfs.block.control.FormatLevelRequest
3, // 47: seaweedfs.block.control.LifecycleService.RetireHost:input_type -> seaweedfs.block.control.RetireHostRequest
38, // 48: seaweedfs.block.control.FailbackService.ExecuteFailback:input_type -> seaweedfs.block.control.FailbackRequest
10, // 49: seaweedfs.block.control.ObservationService.ReportHeartbeat:output_type -> seaweedfs.block.control.HeartbeatAck
43, // 50: seaweedfs.block.control.ObservationService.AnswerProbe:output_type -> seaweedfs.block.control.ProbeAck
11, // 51: seaweedfs.block.control.ObservationService.ReportClusterEvent:output_type -> seaweedfs.block.control.ClusterEventAck
14, // 52: seaweedfs.block.control.AssignmentService.SubscribeAssignments:output_type -> seaweedfs.block.control.AssignmentFact
41, // 53: seaweedfs.block.control.AssignmentService.SubscribeProbeRounds:output_type -> seaweedfs.block.control.ProbeRound
16, // 54: seaweedfs.block.control.EvidenceService.QueryVolumeStatus:output_type -> seaweedfs.block.control.StatusResponse
24, // 55: seaweedfs.block.control.ClusterEvidenceService.GetClusterStatus:output_type -> seaweedfs.block.control.ClusterStatusResponse
29, // 56: seaweedfs.block.control.ClusterEvidenceService.ListVolumes:output_type -> seaweedfs.block.control.ListVolumesResponse
26, // 57: seaweedfs.block.control.ClusterEvidenceService.GetVolumeStatus:output_type -> seaweedfs.block.control.VolumeEvidence
30, // 58: seaweedfs.block.control.ClusterEvidenceService.GetVolumeTimeline:output_type -> seaweedfs.block.control.VolumeTimelineResponse
28, // 59: seaweedfs.block.control.ClusterEvidenceService.WatchClusterEvents:output_type -> seaweedfs.block.control.ClusterEvent
32, // 60: seaweedfs.block.control.LifecycleService.CreateVolume:output_type -> seaweedfs.block.control.CreateVolumeResponse
32, // 61: seaweedfs.block.control.LifecycleService.GetVolume:output_type -> seaweedfs.block.control.CreateVolumeResponse
35, // 62: seaweedfs.block.control.LifecycleService.DeleteVolume:output_type -> seaweedfs.block.control.DeleteVolumeResponse
37, // 63: seaweedfs.block.control.LifecycleService.MarkVolumeDeleting:output_type -> seaweedfs.block.control.MarkVolumeDeletingResponse
37, // 64: seaweedfs.block.control.LifecycleService.AbortVolumeDeleting:output_type -> seaweedfs.block.control.MarkVolumeDeletingResponse
37, // 65: seaweedfs.block.control.LifecycleService.CommitVolumeDeleting:output_type -> seaweedfs.block.control.MarkVolumeDeletingResponse
37, // 66: seaweedfs.block.control.LifecycleService.ReserveVolumeDeletion:output_type -> seaweedfs.block.control.MarkVolumeDeletingResponse
37, // 67: seaweedfs.block.control.LifecycleService.CheckVolumeNoLiveLease:output_type -> seaweedfs.block.control.MarkVolumeDeletingResponse
2, // 68: seaweedfs.block.control.LifecycleService.FinalizeFormat:output_type -> seaweedfs.block.control.FinalizeFormatResponse
45, // 69: seaweedfs.block.control.LifecycleService.FormatLevel:output_type -> seaweedfs.block.control.FormatLevelResponse
4, // 70: seaweedfs.block.control.LifecycleService.RetireHost:output_type -> seaweedfs.block.control.RetireHostResponse
39, // 71: seaweedfs.block.control.FailbackService.ExecuteFailback:output_type -> seaweedfs.block.control.FailbackResponse
49, // [49:72] is the sub-list for method output_type
26, // [26:49] is the sub-list for method input_type
26, // [26:26] is the sub-list for extension type_name
26, // [26:26] is the sub-list for extension extendee
0, // [0:26] is the sub-list for field type_name
@@ -5482,6 +5584,30 @@ func file_control_proto_init() {
return nil
}
}
file_control_proto_msgTypes[43].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*FormatLevelRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_control_proto_msgTypes[44].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*FormatLevelResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
@@ -5489,7 +5615,7 @@ func file_control_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_control_proto_rawDesc,
NumEnums: 1,
NumMessages: 43,
NumMessages: 45,
NumExtensions: 0,
NumServices: 6,
},
@@ -791,6 +791,7 @@ const (
LifecycleService_ReserveVolumeDeletion_FullMethodName = "/seaweedfs.block.control.LifecycleService/ReserveVolumeDeletion"
LifecycleService_CheckVolumeNoLiveLease_FullMethodName = "/seaweedfs.block.control.LifecycleService/CheckVolumeNoLiveLease"
LifecycleService_FinalizeFormat_FullMethodName = "/seaweedfs.block.control.LifecycleService/FinalizeFormat"
LifecycleService_FormatLevel_FullMethodName = "/seaweedfs.block.control.LifecycleService/FormatLevel"
LifecycleService_RetireHost_FullMethodName = "/seaweedfs.block.control.LifecycleService/RetireHost"
)
@@ -830,6 +831,10 @@ type LifecycleServiceClient interface {
// reads_level >= 1 since the master started; the refusal names each one.
// At level 1 it succeeds without writing.
FinalizeFormat(ctx context.Context, in *FinalizeFormatRequest, opts ...grpc.CallOption) (*FinalizeFormatResponse, error)
// FormatLevel reads the cluster's format level (0 or 1), read-only: what a
// client (the snapshot CLI) decides its write route from. A client that
// cannot reach the master runs at level 0.
FormatLevel(ctx context.Context, in *FormatLevelRequest, opts ...grpc.CallOption) (*FormatLevelResponse, error)
// RetireHost removes a registered host from the node inventory, so it no
// longer counts for the format finalize or for placement. Refused
// (FAILED_PRECONDITION, reason HOST_HOLDS_WORK) while the host holds a
@@ -928,6 +933,15 @@ func (c *lifecycleServiceClient) FinalizeFormat(ctx context.Context, in *Finaliz
return out, nil
}
func (c *lifecycleServiceClient) FormatLevel(ctx context.Context, in *FormatLevelRequest, opts ...grpc.CallOption) (*FormatLevelResponse, error) {
out := new(FormatLevelResponse)
err := c.cc.Invoke(ctx, LifecycleService_FormatLevel_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *lifecycleServiceClient) RetireHost(ctx context.Context, in *RetireHostRequest, opts ...grpc.CallOption) (*RetireHostResponse, error) {
out := new(RetireHostResponse)
err := c.cc.Invoke(ctx, LifecycleService_RetireHost_FullMethodName, in, out, opts...)
@@ -973,6 +987,10 @@ type LifecycleServiceServer interface {
// reads_level >= 1 since the master started; the refusal names each one.
// At level 1 it succeeds without writing.
FinalizeFormat(context.Context, *FinalizeFormatRequest) (*FinalizeFormatResponse, error)
// FormatLevel reads the cluster's format level (0 or 1), read-only: what a
// client (the snapshot CLI) decides its write route from. A client that
// cannot reach the master runs at level 0.
FormatLevel(context.Context, *FormatLevelRequest) (*FormatLevelResponse, error)
// RetireHost removes a registered host from the node inventory, so it no
// longer counts for the format finalize or for placement. Refused
// (FAILED_PRECONDITION, reason HOST_HOLDS_WORK) while the host holds a
@@ -1014,6 +1032,9 @@ func (UnimplementedLifecycleServiceServer) CheckVolumeNoLiveLease(context.Contex
func (UnimplementedLifecycleServiceServer) FinalizeFormat(context.Context, *FinalizeFormatRequest) (*FinalizeFormatResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method FinalizeFormat not implemented")
}
func (UnimplementedLifecycleServiceServer) FormatLevel(context.Context, *FormatLevelRequest) (*FormatLevelResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method FormatLevel not implemented")
}
func (UnimplementedLifecycleServiceServer) RetireHost(context.Context, *RetireHostRequest) (*RetireHostResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method RetireHost not implemented")
}
@@ -1192,6 +1213,24 @@ func _LifecycleService_FinalizeFormat_Handler(srv interface{}, ctx context.Conte
return interceptor(ctx, in, info, handler)
}
func _LifecycleService_FormatLevel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(FormatLevelRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(LifecycleServiceServer).FormatLevel(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: LifecycleService_FormatLevel_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(LifecycleServiceServer).FormatLevel(ctx, req.(*FormatLevelRequest))
}
return interceptor(ctx, in, info, handler)
}
func _LifecycleService_RetireHost_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RetireHostRequest)
if err := dec(in); err != nil {
@@ -1253,6 +1292,10 @@ var LifecycleService_ServiceDesc = grpc.ServiceDesc{
MethodName: "FinalizeFormat",
Handler: _LifecycleService_FinalizeFormat_Handler,
},
{
MethodName: "FormatLevel",
Handler: _LifecycleService_FormatLevel_Handler,
},
{
MethodName: "RetireHost",
Handler: _LifecycleService_RetireHost_Handler,
@@ -26,6 +26,11 @@ const (
// ReasonHostHoldsWork: a host retire was refused because the host still
// holds a lease or an assignment for a volume.
ReasonHostHoldsWork = "HOST_HOLDS_WORK"
// ReasonAwaitingFirstReport: new work was refused because the named node
// has not reported which format level its binary reads (no heartbeat
// since the master started) and the cluster's level is above 0; unknown
// counts as old. Retryable: it clears with the node's first report.
ReasonAwaitingFirstReport = "AWAITING_FIRST_REPORT"
)
// WithReason returns st with an ErrorInfo detail carrying reason in
@@ -126,6 +126,10 @@ service LifecycleService {
// reads_level >= 1 since the master started; the refusal names each one.
// At level 1 it succeeds without writing.
rpc FinalizeFormat(FinalizeFormatRequest) returns (FinalizeFormatResponse);
// FormatLevel reads the cluster's format level (0 or 1), read-only: what a
// client (the snapshot CLI) decides its write route from. A client that
// cannot reach the master runs at level 0.
rpc FormatLevel(FormatLevelRequest) returns (FormatLevelResponse);
// RetireHost removes a registered host from the node inventory, so it no
// longer counts for the format finalize or for placement. Refused
// (FAILED_PRECONDITION, reason HOST_HOLDS_WORK) while the host holds a
@@ -689,3 +693,10 @@ message ProbeAnswer {
}
message ProbeAck {}
// FormatLevel (LifecycleService) reads the cluster's format level.
message FormatLevelRequest {}
message FormatLevelResponse {
uint32 format_level = 1;
}
+1
View File
@@ -654,6 +654,7 @@ The "Machine / transition" column refers to Part A. Notes under a table record w
| `INV-CHUNK-RECORD-SHADOW-001` | While serving, the chunk record follows the engine's events via the kernel; an event bound to a captured version is skipped, never refused, after a write; at each barrier every chunk the engine captures is a record candidate. It decides nothing; on v1.0 it writes no page. | M3 Serving (chunk record shadow) | `core/storage/chunk_record_shadow.go` `newChunkRecordShadow`, `chunkRecordShadow.check`; `core/storage/chunk_layer.go` `noteMutation`, `fillOnce`, `EvictChunk`, `recoveredLocked`, `BeforeCheckpointAdvance`, `shadowCommit`, `shadowCommitCaptured` (also from `resolvePending`, `SettleDetach`); `core/storage/chunk_cut_payload.go` `markEqualNow`; `core/storage/chunk_record_runtime.go` `ApplyIf` | `TestShadowWriteCoverageFollowsTheStoreBitmap`, `TestShadowFillRacedByAWriteEndsUnknown`, `TestShadowCutOfAPartialChunkKeepsItPartial`, `TestShadowCommitAfterAChunkLandedSinceItsScratchCaptureIsSkipped`, `TestShadowExtentWritesLandAnAbsentChunkOnlyOnV10`, `TestShadowAttachKeepsACheckpointedWriteACandidate`, `TestShadowWriteRacingHashAndCommitIsSkippedNotRefused`, `TestShadowEvictEdges`, `TestShadowRecordWritesNoPage`, `TestShadowCheckerIsExactAndCatchesAMissingWrite`, `TestShadowRecoverChangesOnlyTheRecoveredChunks`, `TestShadowBaseInstallCompletingChangesEveryChunk`, `TestShadowDelayedSettlementCommitsTheCapturedChunks`, `TestShadowProductionCheckDoesNotScanTheRecord`, `TestShadowScratchExemptionIsBoundToItsCapturedVersion` (`core/storage/chunk_record_shadow_test.go`); every test of the package runs with the shadow strict, misses and extra record candidates both (`TestMain`, `core/storage/chunk_record_shadow_main_test.go`) | chunk-kernel/2 (the per-chunk state models are not in this repository) | ACTIVE |
| `INV-CHUNK-RECORD-V11-001` | On the draft v1.1 format a layer upgrades its store once at attach and opens from its record; a fill's page claims no local block before one durable mark (partial fills and later writes too); an evict clears the store's bits only after its absent page is durable, retries too. | M1 Opened, M3 Serving (draft v1.1 format) | `core/storage/chunk_record_open.go` `openChunkRecordV11`, `loadChunkRecordV11`, `markFills`; `core/storage/chunk_record_upgrade.go` `upgradeChunkRecordWith`; `core/storage/chunk_record_runtime.go` `holdFills`, `PersistSegmentOf`; `core/storage/chunk_record_shadow.go` `evict`; `core/storage/chunk_layer.go` `EvictChunk`, `Close` | `TestV11AttachUpgradesTheStoreOnce`, `TestV11ReopenJudgesAWriteAfterThePageAsChanged`, `TestV11CleanStopWritesOnlyTheDirtyPages`, `TestV11UpgradeRecoversFromACrashAtEachStep`, `TestV11DamagedPageIsRebuiltFromTheStoreBits`, `TestV11FillsAreMarkedInOneBatchBeforeTheirPagesClaimThem`, `TestV11EvictSurvivesARestart` (`core/storage/chunk_record_v11_test.go`); `TestV11CloseDuringTheUpgradeRefusesTheAttach`, `TestV11EvictWithoutItsAbsentPageClearsNothing`, `TestV11ParkedFillBatchCannotOverwriteAnEvict`, `TestV11MalformedLeftoverPresenceDoesNotRefuseTheAttach`, `TestV11FinalPageFailureIsTheCloseResult` (`core/storage/chunk_record_v11_review_test.go`); `TestV11PartialFillWaitsForTheDurableMark`, `TestV11WriteAfterAHeldFillKeepsTheHold`, `TestV11EvictRetryStillWritesItsAbsentPage` (`core/storage/chunk_record_v11_hold_test.go`); `TestV11AbsentChunkSurvivesALostHeader`, `TestV11LogOnlyWriteSurvivesTheUpgrade` (`core/storage/chunk_record_v11_upgrade_test.go`) | chunk-kernel/2; CoverageDurable row 199 (the WAL is durable through a published position) (not in this repository) | DORMANT |
| `INV-CHUNK-FORMAT-LEVEL-001` | An attach raises a volume to v1.1 only at the assigned format level 1 (absent = 0); at level 0 it runs v1.1 only over a version-1 HEAD (reported), refuses a v1.1 store over a version-0 HEAD, and a v1.1 attach refuses a remote without the HEAD format. | M-format gate (holder) | `core/storage/chunk_v11_format.go` `attachLevelV11`, `levelZeroFormat`; `core/storage/chunk_layer.go` `attachChunkLayerImpl`; `core/frontend/chunkstore/layout/format_level.go` `checkFormatLevel` (in `runTransition`); `core/frontend/chunkstore/layout_remote.go` `SetHeadFormat`, `HeadV11`; `core/host/volume/host.go` `applyFact`; `core/frontend/durable/provider_chunk.go` `attachFormatLevel` | `TestAttachFormatFollowsTheAssignedLevel`, `TestAttachAtLevelZeroOfAnUpgradedStore`, `TestAttachAtLevelZeroOfAV11HeadOverAnUnmarkedStore`, `TestAV11AttachRefusesARemoteWithoutTheHeadFormat`, `TestALevelOneCrashBeforeTheFirstCutReattachesAsV11`, `TestAV11AttachRefusesARemoteThatDeclinesTheHeadFormat` (`core/storage/chunk_format_level_test.go`); `TestLayoutRemoteHeadFormatFollowsItsLayer`, `TestALevelZeroCommitCannotRaiseHeadToVersionOne` (`core/frontend/chunkstore/layout_manifest_size_test.go`); `TestNoHeadWriteRaisesTheVersionBelowFormatLevelOne` (`core/frontend/chunkstore/layout/format_level_test.go`); `TestTheWrappedRemoteForwardsTheHeadFormatBothWays`, `TestAttachFormatLevelFromTheAssignment` (`core/frontend/durable/format_level_test.go`); `TestTheAssignedLevelDecidesTheStoredHeadAcrossARestart` (`core/frontend/durable/format_level_layout_test.go`); `TestTheSelfAssignmentsFormatLevelReachesTheProjection` (`core/host/volume/format_level_test.go`) | none | ACTIVE |
| `INV-MASTER-FORMAT-LEVEL-001` | A master with no prior authority state starts at format level 1, written before it serves; existing state keeps its level; above level 0 a node with no reported read level gets no new work, refused typed and retryable (awaiting_first_report). | M-format gate (master) | `core/host/master/host.go` `New`; `core/host/master/store_attestation.go` `newClusterAtStart`; `core/host/master/format_gate.go` `FormatLevel`, `awaitingFirstReport`, `formatRefusal`; `core/host/master/observation_snapshot.go` `ObservationSnapshot` | `TestOnlyANewClusterStartsAtLevelOne`, `TestANewClusterStartsAtTheCurrentFormatLevel`, `TestANewClusterPlacesOnANodeOnlyAfterItsFirstReport` (`core/host/master/format_level_new_cluster_test.go`); `TestClusterFormatLevel` (`cmd/sw-block/cluster_format_test.go`) | none | ACTIVE |
| `INV-CHUNK-FOREIGN-ROOT-FENCE-001` | A HEAD that moved past the holder's base without superseding it and is not its own proposal must keep the chunk root; one that changed it fences the layer (`errChunkForeignRoot`), so no chunk is held clean against a root that no longer names it. | M5 Commit (head conflict, settlement) | `core/storage/chunk_layer.go` `adoptHeadLocked` (from `captureLocked`, `SettleDetach`, `resolvePending`) | `TestShadowForeignRootWithoutSupersedeFences` (`core/storage/chunk_record_shadow_test.go`) | HeadWriters (only metadata writers move HEAD without superseding; not in this repository) | ACTIVE |
| `INV-CHUNK-RECORD-PAYLOAD-001` | Persisting and loading a chunk record preserves every entry's state and hash, including entries on either side of a segment boundary. | M1 chunk record codec (caller not wired) | `core/storage/chunk_record.go` `encodeChunkRecordPage`, `decodeChunkRecordPage` | `TestRecordEntryPayloadRoundTripsAcrossSegments` (`core/storage/chunk_record_test.go`; state-zero and one-entry hash-drop controls) | Encoding fidelity; no state transition change | STUB |
| `INV-CHUNK-COVERAGE-INIT-POSITION-001` | Coverage initialization rechecks the captured append position under the final store lock before publishing a fence or replacing live entries; a changed position refuses the candidate. | M1 coverage initialization | `core/storage/chunk_coverage.go` `InitializeChunkCoverage` | `TestChunkCoverageInitializationRefusesAnAppendDuringPagePreparation`, `TestChunkCoverageInitializationCaptureBarrierExcludesPublicWrites` (`core/storage/chunk_coverage_initialization_append_test.go`) | SlotFence.Publish; capture barrier remains the public-write exclusion | ACTIVE |