mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
fix: fail closed when the filer client cannot run its census
This commit is contained in:
1 parent
7380604134
commit
3d6ecf548d
5 files changed
+15
-2
No files matched your search
@@ -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 })
|
||||
}
|
||||
@@ -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"),
|
||||
|
||||
@@ -832,6 +832,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 |
|
||||
|
||||
Reference in new issue
Block a user