From 96229aec75b4deadb8b07fa7774d64cd217dfcd9 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 29 Nov 2026 19:28:23 -0800 Subject: [PATCH] test: classify isolated startup probe identity mint --- .../chunkstore/startup_head_probe_test.go | 17 ++++++++++++++++ .../lifecycle/layout_identity_guard_test.go | 20 +++++++++++++++++-- seaweed-block/docs/design/invariants.md | 2 +- seaweed-block/docs/standalone-deployment.md | 6 +++++- 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/seaweed-block/core/frontend/chunkstore/startup_head_probe_test.go b/seaweed-block/core/frontend/chunkstore/startup_head_probe_test.go index c5aa628e5e..3ee81755ad 100644 --- a/seaweed-block/core/frontend/chunkstore/startup_head_probe_test.go +++ b/seaweed-block/core/frontend/chunkstore/startup_head_probe_test.go @@ -12,6 +12,7 @@ import ( "time" "github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/filerpb" + "github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -22,9 +23,13 @@ type conditionalProbeServer struct { store *fakeFiler mode string updates int + creates []*filerpb.CreateEntryRequest } func (f *conditionalProbeServer) CreateEntry(ctx context.Context, r *filerpb.CreateEntryRequest) (*filerpb.CreateEntryResponse, error) { + f.mu.Lock() + f.creates = append(f.creates, r) + f.mu.Unlock() if err := f.store.CreateEntry(ctx, r.Directory, r.Entry, r.OExcl); err != nil { return nil, status.Error(codes.Internal, err.Error()) } @@ -114,7 +119,19 @@ func TestCatalogStartupRequiresWrongGenerationHeadRefusal(t *testing.T) { } f.mu.Lock() updates := f.updates + creates := append([]*filerpb.CreateEntryRequest(nil), f.creates...) f.mu.Unlock() + // This mint is a disposable HEAD label, not an alternate volume + // creator. No VOLUME, lifecycle identity or real volume root is used. + if len(creates) != 1 { + t.Fatalf("probe created %d entries; want only its disposable HEAD", len(creates)) + } + created := creates[0] + name := path.Base(created.Directory) + probeID := strings.TrimPrefix(name, ".startup-head-probe-") + if !created.OExcl || path.Dir(created.Directory) != "/blocks" || name == probeID || len(probeID) != 32 || created.Entry.GetName() != layout.HeadName || string(created.Entry.Extended[layoutVolume]) != probeID { + t.Fatalf("probe mint escaped its exclusive HEAD namespace: %+v", created) + } if updates != 1 { t.Fatalf("wrong-generation exchanges=%d want1", updates) } diff --git a/seaweed-block/core/lifecycle/layout_identity_guard_test.go b/seaweed-block/core/lifecycle/layout_identity_guard_test.go index b84010b7d4..e6c9228d5c 100644 --- a/seaweed-block/core/lifecycle/layout_identity_guard_test.go +++ b/seaweed-block/core/lifecycle/layout_identity_guard_test.go @@ -11,6 +11,14 @@ import ( ) func TestLayoutIdentityWriterAndReaders(t *testing.T) { + // Product volume identities still come only from lifecycle create. The + // one other mint is an isolated metadata capability probe, never a VOLUME + // or a lifecycle record; its RPC containment is tested at catalog startup. + mintSites := map[string]string{ + "core/lifecycle/store.go CreateVolume": "durable lifecycle volume identity", + "core/frontend/chunkstore/startup_head_probe.go checkConditionalHead": "disposable HEAD only, exclusive create in its random probe namespace; TestCatalogStartupRequiresWrongGenerationHeadRefusal", + } + seenMints := map[string]bool{} want := map[string]bool{ "core/lifecycle/store.go CreateVolume": true, "core/lifecycle/store.go volumeSpecsCompatible": true, @@ -85,8 +93,11 @@ func TestLayoutIdentityWriterAndReaders(t *testing.T) { t.Errorf("layout identity reader/writer needs a probe: %s", site) } } - if s.Sel.Name == "NewVolumeID" && site != "core/lifecycle/store.go CreateVolume" { - t.Errorf("layout identity minted outside lifecycle create: %s", site) + if s.Sel.Name == "NewVolumeID" { + seenMints[site] = true + if mintSites[site] == "" { + t.Errorf("layout identity mint needs a classified reason and probe: %s", site) + } } } return true @@ -98,6 +109,11 @@ func TestLayoutIdentityWriterAndReaders(t *testing.T) { t.Fatal(err) } } + for site := range mintSites { + if !seenMints[site] { + t.Errorf("classified identity mint site no longer exists: %s", site) + } + } for site := range want { if !seen[site] { t.Errorf("missing identity probe site %s", site) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 6f356a402c..648c367133 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -831,7 +831,7 @@ Notes: | `INV-WS-STALE-LOCAL-ROOT-001` | An old or rolled-back local root is refused by `layout.Start` before serving; synchronous and deferred attach end without retry and report the typed stale-root error and cure. A fresh root at its own epoch likewise ends with `ErrMissingLocalRoot` and its cure. | M4 Claiming → Refused | `core/frontend/durable/provider_layout.go` `startLayoutRoot`; `core/frontend/durable/provider_chunk.go` `recoverChunk`, `chunkAuthorityWait`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `TestLayoutProviderRefusesEmptyOwnEpochAndRemountedOldRoot`, `TestFinalLayoutStartRefusalTable` (`core/frontend/durable/provider_layout_test.go`, `provider_layout_start_class_test.go`) | — | ACTIVE | | `INV-WS-ONE-PROCESS-PER-HOST-001` | One host runs at most one live blockvolume per volume: each takes the volume's exclusive host lock before its store opens and holds it until the store closes; a second is refused before it opens anything, whatever its `--durable-root`. | M4 (start) → Attaching, Refused | `core/frontend/durable/provider.go` `DurableProvider.lockVolumeOnHost` | `TestOneLiveProcessPerVolumePerHost`, `TestHostVolumeLockDirectoryCreatedOrRefused`, `TestHostVolumeLockRefusesNonDirectoryLockPath`, `TestHostVolumeLockTakesReadOnlyLockFile` (`core/frontend/durable/one_process_per_volume_test.go`); `TestHostVolumeLockCreatesParent0755AndLocks0700`, `TestHostVolumeLockKeepsExistingDirectoryModes` (`core/frontend/durable/volume_lock_parent_mode_test.go`); `TestVolumeLockDirTestOnlyRefusedUnderSystemd` (`cmd/blockvolume/volume_lock_flag_test.go`) | — | ACTIVE | | `INV-CHUNK-LEASE-REQUIRED-001` | Blockvolume refuses walstore-chunk startup without --workspace-lease before any host or store is opened. The refusal names concurrent acknowledging writers and acknowledged-write loss after a forced move; plain walstore startup is unchanged. | M4 startup → Refused | `cmd/blockvolume/main.go` `parseFlags` | `TestChunkVolumeRequiresWorkspaceLeaseBeforeStart` | — | ACTIVE | -| `INV-WS-CONDITIONAL-HEAD-001` | Catalog startup requires a wrong-generation conditional update of a disposable HEAD to be definitely refused and leave its bytes and generation unchanged. Unknown probe outcomes refuse admission; cleanup failures only warn with the leftover path. No volume HEAD is used. | M4 startup → Refused | `core/frontend/chunkstore/swfs_catalog.go` `DialBCatalog`; `startup_head_probe.go` `checkConditionalHead` | `TestCatalogStartupRequiresWrongGenerationHeadRefusal` | — | ACTIVE | +| `INV-WS-CONDITIONAL-HEAD-001` | Catalog startup requires a wrong-generation conditional update of a disposable HEAD to be definitely refused and leave its bytes and generation unchanged. Unknown probe outcomes refuse admission; cleanup failures only warn with the leftover path. No volume HEAD is used. | M4 startup → Refused | `core/frontend/chunkstore/swfs_catalog.go` `DialBCatalog`; `startup_head_probe.go` `checkConditionalHead` | `TestCatalogStartupRequiresWrongGenerationHeadRefusal`, `TestLayoutIdentityWriterAndReaders` | — | ACTIVE | | `INV-WS-SINGLE-FILER-001` | Startup requires all configured masters to answer and agree on a leader; only that leader listing exactly the target filer and confirming leadership afterward admits. Followers' lists do not decide. Unknown views retry within 60 s. This census does not fence later filer registration. | M4 (startup) → Refused | `core/frontend/chunkstore/single_filer.go` `CheckSingleFiler`; `cmd/blockvolume/chunk_remote.go` `newChunkWiring`; `cmd/sw-block/chunk.go` `refuseUnlessSingleFiler` | `TestSingleFilerCensusUsesTheAgreedLeader`; `TestCheckSingleFilerRefusesAnotherOrSeveralFilers`, `TestCheckSingleFilerFailsClosed`, `TestCheckSingleFilerNeedsEveryMasterToAnswer`, `TestIsTargetComparesScopedAddresses`, `TestCheckSingleFilerPasses` (`core/frontend/chunkstore/single_filer_test.go`), `TestChunkWiringRefusesAMultiFilerGroup` (`cmd/blockvolume/single_filer_test.go`), `TestOpsChunk_WritingCommandsRunTheSingleFilerCheck` (`cmd/sw-block/chunk_start_check_test.go`), `TestOpsChunk_VerifyRunsTheSingleFilerCheck` (`cmd/sw-block/chunk_verify_test.go`) | — | ACTIVE | | `INV-WS-LEASE-REGRANT-001` | Re-grant after expiry keeps the same holder and epoch, with no pending move or revocation, a certain store, and one durable write after the horizon/deadline plus skew barrier. Restart begins a new session and voids the old; ordinary reopen keeps HEAD identity (epoch, holder, claim) unchanged. | M2 Expired → Granted; M9 Start | `core/authority/workspace_lease_view.go` `regrantWorkspaceLease`; `core/authority/workspace.go` `forcedMoveBarrierLocked`; `core/frontend/chunkstore/layout/start.go` `Start` | `TestWorkspaceLeaseExpiredSameHolderRegrantIsDurable`, `TestWorkspaceLeaseRegrantWaitsForFullSkew`, `TestWorkspaceLeaseRegrantDefeatsAlreadyPassedForcedPreflight`, `TestWorkspaceLeaseForcedIssueDefeatsOldHolderRegrant`, `TestWorkspaceLeaseRegrantWaitsForDurabilityAndLatchesFailure` (`core/authority/workspace_regrant_test.go`); `TestWorkspaceLeaseRegrantPreservesLocalLogThroughFirstCut` (`core/authority/workspace_regrant_storage_test.go`); `TestStart_OwnEpochFreshRootRefusedBeforeClaim`, `TestStart_OwnEpochSameRootContinues` (`core/frontend/chunkstore/layout/start_test.go`); `TestClaim_WritesItsClaimID`, `TestRunClaim_VoidsTheOldSession` (`core/frontend/chunkstore/layout/claim_test.go`); `TestLocalReopenClaimsBeforeServing` (`core/frontend/durable/provider_reopen_belt_test.go`) | `WorkspaceRegrant` `NoDualServingInc`, `RegrantNoLoss`, `DiskCoversMemory`; `INV-SNAPK-START-ROOT-001` | ACTIVE | | `INV-WS-LEASE-001` | A host admits frontend I/O and cuts only under an unexpired lease for its exact `{volume, replica, epoch}`; a fenced guard never reopens, even on a late renewal reply. | M4 lease guard: Valid → Fenced | `core/host/volume/workspace_lease.go` `permits`, `Refresh` | `TestWorkspaceLeaseExpiryFencesWithoutTimerAndCannotReopen`, `TestWorkspaceDelayedRenewalCannotUndoExpiry` (`core/host/volume/workspace_lease_test.go`); `TestWorkspaceHostRequiresLeaseBeforeFrontendAndCut` (`core/host/volume/workspace_runtime_test.go`); `TestWorkspacePausedGranteeRefusedAtAttach` (`core/host/master/workspace_paused_grantee_test.go`) | `WorkspaceTakeover` `NoDualServing` | ACTIVE | diff --git a/seaweed-block/docs/standalone-deployment.md b/seaweed-block/docs/standalone-deployment.md index b087330829..0538b0f1b9 100644 --- a/seaweed-block/docs/standalone-deployment.md +++ b/seaweed-block/docs/standalone-deployment.md @@ -1023,7 +1023,11 @@ remain unchanged. An accepted wrong-generation update, an ambiguous answer or a changed probe refuses startup. Only the filer's definite failed-condition answer qualifies; a missing-entry answer does not prove the condition was checked. A cleanup failure logs the leftover path and does -not refuse a start whose probe succeeded. No volume HEAD or chunk payload is touched. +not refuse a start whose probe succeeded. No volume HEAD or chunk payload is touched. The random identity labels only this +probe's HEAD and directory; it is never registered as a lifecycle volume or +written into a VOLUME entry. The identity-mint guard explicitly classifies this +isolated capability check; actual volume identities still come from lifecycle +create. The exchange is bounded by 10 seconds plus up to 5 seconds for non-recursive cleanup, in addition to the single-filer census. The service account needs