Merge #774 3d6ecf54 into train/20261130-t3

This commit is contained in:
pingqiu committed 2026-11-29 19:59:56 -08:00
commit 9faa50d629
6 files changed
+56 -2

No files matched your search

+2 -2
View File
@@ -48,10 +48,10 @@ var dialChunkFiler = func(addr string) (chunkstore.Filer, func() error, error) {
// metadata: block metadata goes through exactly one filer, the
// same rule blockvolume enforces at start. Tests replace it.
var checkSingleFiler = func(ctx context.Context, f chunkstore.Filer) error {
if s, ok := f.(*chunkstore.SWFS); ok {
if s, ok := f.(*chunkstore.SWFS); ok && s != nil {
return s.CheckSingleFiler(ctx)
}
return nil
return fmt.Errorf("%w: single-filer census requires a live SWFS client, got %T", chunkstore.ErrNotSingleFiler, f)
}
// refuseUnlessSingleFiler runs the start check within the command's own
@@ -57,6 +57,7 @@ var testIDs sync.Map
// names against testIDs.
func useMemChunkStore(t *testing.T, store *memChunkStore) {
t.Helper()
assumeSingleFilerFixture(t)
prev, prevResolve, prevRestore := dialChunkFiler, resolveVolumeID, restoreCreateRPC
dialChunkFiler = func(string) (chunkstore.Filer, func() error, error) { return store, func() error { return nil }, nil }
resolveVolumeID = testResolve
@@ -429,3 +430,12 @@ func TestOpsChunkVolumeDeleteRequiresTheMastersLeaseProof(t *testing.T) {
t.Fatalf("HEAD changed despite refused proof: %+v %v %v", h, found, err)
}
}
// Catalog fixtures model one in-memory namespace; inject that census result
// explicitly. Production clients must perform the live SWFS group census.
func assumeSingleFilerFixture(t *testing.T) {
t.Helper()
prev := checkSingleFiler
checkSingleFiler = func(context.Context, chunkstore.Filer) error { return nil }
t.Cleanup(func() { checkSingleFiler = prev })
}
@@ -3,6 +3,7 @@ package main
import (
"bytes"
"context"
"errors"
"strings"
"testing"
"time"
@@ -142,3 +143,43 @@ func TestOpsChunk_StartCheckIsBoundedByTheTimeout(t *testing.T) {
}
}
}
// A filer implementation that cannot run the real group census must never
// be mistaken for a successful single-filer observation.
func TestSingleFilerCheckRefusesUnsupportedClients(t *testing.T) {
for _, tc := range []struct {
name string
filer chunkstore.Filer
}{
{"memory", chunkstore.NewMemFiler()},
{"nil", nil},
{"typed nil", (*chunkstore.SWFS)(nil)},
} {
t.Run(tc.name, func(t *testing.T) {
defer func() {
if r := recover(); r != nil {
t.Fatalf("start check panicked instead of refusing: %v", r)
}
}()
if err := checkSingleFiler(context.Background(), tc.filer); !errors.Is(err, chunkstore.ErrNotSingleFiler) {
t.Fatalf("unsupported filer start check: %v; want typed refusal", err)
}
})
}
}
func TestOpsChunkWritingRefusesUnsupportedFilerBeforeCatalogAccess(t *testing.T) {
mem := newMemChunkStore()
prevDial, prevResolve := dialChunkFiler, resolveVolumeID
t.Cleanup(func() { dialChunkFiler, resolveVolumeID = prevDial, prevResolve })
closed := false
dialChunkFiler = func(string) (chunkstore.Filer, func() error, error) {
return mem, func() error { closed = true; return nil }, nil
}
resolveVolumeID = func(context.Context, string, string) (layout.VolumeID, error) { return layout.VolumeID{1}, nil }
code, out, errs := runChunk("retain", "--volume", "v1", "--master", "master:1", "--chunk-filer", "filer:18888")
answer := chunkErrorOut(t, out)
if code != 2 || answer.Code != codeBadRequestCLI || answer.Retryable || !strings.Contains(answer.Message, "SWFS") || !closed || len(mem.blobs) != 0 {
t.Fatalf("unsupported filer was not refused before catalog work: exit=%d out=%s err=%s closed=%v blobs=%d", code, out, errs, closed, len(mem.blobs))
}
}
@@ -19,6 +19,7 @@ import (
// one root naming chunks 0 and 1) on an in-memory filer and blob store; it
// returns the store and chunk 1's pool path.
func verifyCLIFixture(t *testing.T) (*manifestFixtureFiler, string) {
assumeSingleFilerFixture(t)
t.Helper()
ctx := context.Background()
mem := newManifestFixtureFiler(chunkstore.NewMemFiler())
@@ -318,6 +318,7 @@ func serveRestoreMaster(t *testing.T) (*restoreMaster, string) {
t.Fatal(err)
}
prev := dialChunkFiler
assumeSingleFilerFixture(t)
dialChunkFiler = func(string) (chunkstore.Filer, func() error, error) { return store, func() error { return nil }, nil }
t.Cleanup(func() { dialChunkFiler = prev })
m := &restoreMaster{vols: map[string]*restoreRec{}, ids: map[string]layout.VolumeID{}, cat: cat, src: cliVolume(t, store, "vol-a", "s1"),
+1
View File
@@ -835,6 +835,7 @@ Notes:
| `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-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-CLI-SINGLE-FILER-CLIENT-001` | Chunk metadata commands refuse missing, typed-nil and non-SWFS clients before catalog access; only a live SWFS client can run the census. | M4 startup client admission | `cmd/sw-block/chunk.go` `checkSingleFiler`, `refuseUnlessSingleFiler` | `TestSingleFilerCheckRefusesUnsupportedClients`, `TestOpsChunkWritingRefusesUnsupportedFilerBeforeCatalogAccess` | — (client capability guard) | 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 |
| `INV-WS-REVOKE-ACK-RECORDED-001` | A matching recorded revocation stop is answered before lease checks without writing or extending the lease. An expired lease still refuses a first ACK, and a changed replica, epoch, holder or stopped position never replays another ACK. | M2 revocation ACK replay, no state change | `core/authority/workspace.go` `AckWorkspaceRevocation` | `TestRecordedRevocationAckRetryAfterDeadline`, `TestRecordedAckLostReplyAfterMasterDeadlineDrainsWithoutRetryExit`, `TestUnrecordedRevocationAckStillRefusesAfterDeadline` | WorkspaceTakeover CleanNoLoss; replay stutters | ACTIVE |