diff --git a/seaweed-block/.github/scripts/lab-tag-check-test.sh b/seaweed-block/.github/scripts/lab-tag-check-test.sh new file mode 100644 index 0000000000..52da1df63f --- /dev/null +++ b/seaweed-block/.github/scripts/lab-tag-check-test.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# Controls for lab-tag-check.sh: clean tree passes; the tag in a Dockerfile or +# in the publish workflow fails; in test.yml it passes. +set -euo pipefail +here=$(cd "$(dirname "$0")" && pwd) +t=$(mktemp -d); trap 'rm -rf -- "${t:?}"' EXIT +mkdir -p "$t/deploy/k8s" "$t/.github/workflows" +echo 'RUN go build ./cmd/blockvolume' > "$t/deploy/k8s/Dockerfile.x" +echo 'run: go build ./...' > "$t/.github/workflows/publish.yml" +echo 'run: go test -tags swblock_lab_bigvol ./core/geometry/' > "$t/.github/workflows/test.yml" +bash "$here/lab-tag-check.sh" "$t" >/dev/null || { echo "FAIL: clean tree refused"; exit 1; } +echo 'RUN go build -tags swblock_lab_bigvol ./cmd/blockvolume' > "$t/deploy/k8s/Dockerfile.x" +if bash "$here/lab-tag-check.sh" "$t" >/dev/null; then echo "FAIL: tag in a Dockerfile passed"; exit 1; fi +echo 'RUN go build ./cmd/blockvolume' > "$t/deploy/k8s/Dockerfile.x" +echo 'run: go build -tags swblock_lab_bigvol ./...' > "$t/.github/workflows/publish.yml" +if bash "$here/lab-tag-check.sh" "$t" >/dev/null; then echo "FAIL: tag in the publish workflow passed"; exit 1; fi +echo "lab-tag-check controls: OK" diff --git a/seaweed-block/.github/scripts/lab-tag-check.sh b/seaweed-block/.github/scripts/lab-tag-check.sh new file mode 100644 index 0000000000..50d31342da --- /dev/null +++ b/seaweed-block/.github/scripts/lab-tag-check.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# The lab-only build tag swblock_lab_bigvol lifts the 256 GiB create cap and +# the local headroom refusal for scale rehearsals. No image or release build +# may carry it: refuse the tag anywhere under deploy/ (the image Dockerfiles) +# and in every workflow but test.yml, whose lab job only tests it. +# Usage: lab-tag-check.sh [REPO_ROOT] Exit 0: clean. Exit 1: a hit (printed). +set -euo pipefail +root=${1:-.} +tag=swblock_lab_bigvol +hits=$(grep -rln -- "$tag" "$root/deploy" "$root/.github/workflows" 2>/dev/null | grep -v -- '/\.github/workflows/test\.yml$' || true) +if [ -n "$hits" ]; then + echo "lab-tag: $tag must not be in an image or release build:" + echo "$hits" + exit 1 +fi +echo "lab-tag: clean" diff --git a/seaweed-block/.github/workflows/test.yml b/seaweed-block/.github/workflows/test.yml index d0ea15f592..e5d25a49f2 100644 --- a/seaweed-block/.github/workflows/test.yml +++ b/seaweed-block/.github/workflows/test.yml @@ -100,6 +100,19 @@ jobs: if: matrix.suite == 'unit' run: go vet ./... + - name: Lab build tag stays out of images and releases + if: matrix.suite == 'unit' + # swblock_lab_bigvol lifts the 256 GiB create cap and the local + # headroom refusal for scale rehearsals only. The default test run + # pins the release cap (TestReleaseBuildKeepsTheCreateCap); this step + # refuses the tag in any image or release build and tests the lab build. + run: | + set -euo pipefail + bash .github/scripts/lab-tag-check.sh . + bash .github/scripts/lab-tag-check-test.sh + go vet -tags swblock_lab_bigvol ./core/geometry/ ./core/frontend/durable/ + go test -count=1 -tags swblock_lab_bigvol -run 'Lab|Headroom' ./core/geometry/ ./core/frontend/durable/ + - name: Test default configuration if: matrix.suite == 'unit' # The runner disk is shared, so the long, disk-heavy, timing-sensitive diff --git a/seaweed-block/core/frontend/durable/headroom.go b/seaweed-block/core/frontend/durable/headroom.go index fcfd199003..a319255117 100644 --- a/seaweed-block/core/frontend/durable/headroom.go +++ b/seaweed-block/core/frontend/durable/headroom.go @@ -4,6 +4,7 @@ import ( "fmt" "log" + "github.com/seaweedfs/seaweed-block/core/geometry" "github.com/seaweedfs/seaweed-block/core/storage" ) @@ -22,7 +23,17 @@ func (p *DurableProvider) refuseCreateWithoutHeadroom(volumeID string) error { } have, err := free() size := int64(p.cfg.NumBlocks) * int64(p.cfg.BlockSize) - if need := size + storage.DefaultWALBytes; err == nil && have < need { + need := size + storage.DefaultWALBytes + if geometry.LabBigVolume { + // A lab build (swblock_lab_bigvol): scale rehearsals create sparse + // volumes far larger than the disk. Warn, never refuse. + if err == nil && have < need { + log.Printf("durable: LAB BUILD: creating volume %s with %d bytes free on %s, below its size %d + WAL %d; guest writes fail when the disk fills", + volumeID, have, p.cfg.StorageRoot, size, storage.DefaultWALBytes) + } + return nil + } + if err == nil && have < need { return fmt.Errorf("durable: %s has %d bytes free; volume %s needs %d (size %d + WAL %d): free space on it or use a larger file system", p.cfg.StorageRoot, have, volumeID, need, size, storage.DefaultWALBytes) } diff --git a/seaweed-block/core/frontend/durable/headroom_lab_test.go b/seaweed-block/core/frontend/durable/headroom_lab_test.go new file mode 100644 index 0000000000..c9e1033625 --- /dev/null +++ b/seaweed-block/core/frontend/durable/headroom_lab_test.go @@ -0,0 +1,23 @@ +//go:build swblock_lab_bigvol + +package durable_test + +import ( + "testing" + + "github.com/seaweedfs/seaweed-block/core/frontend/durable" +) + +// A lab build creates a volume larger than the local free space, with a +// warning, where a release build refuses (TestCreateRefusesWithoutLocalHeadroom). +func TestLabBuildCreatesWithoutLocalHeadroom(t *testing.T) { + defer durable.SetRootFreeForTest(8 << 20)() + p, err := durable.NewDurableProvider(durable.ProviderConfig{Impl: durable.ImplWALStore, StorageRoot: t.TempDir(), BlockSize: 4096, NumBlocks: 65536}, v1View()) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { p.Close() }) + if _, err := p.EnsureStorage("v1"); err != nil { + t.Fatalf("a lab build refused a create without headroom: %v", err) + } +} diff --git a/seaweed-block/core/frontend/durable/headroom_test.go b/seaweed-block/core/frontend/durable/headroom_test.go index f11e4a55bd..35310b51c1 100644 --- a/seaweed-block/core/frontend/durable/headroom_test.go +++ b/seaweed-block/core/frontend/durable/headroom_test.go @@ -10,6 +10,7 @@ import ( "github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout" "github.com/seaweedfs/seaweed-block/core/frontend/durable" + "github.com/seaweedfs/seaweed-block/core/geometry" "github.com/seaweedfs/seaweed-block/core/storage" ) @@ -17,6 +18,9 @@ import ( // and its WAL (operator guide, Size a host; issue 484), and a refused create // leaves nothing behind: no store, no chunk fresh marker or other sidecar. func TestCreateRefusesWithoutLocalHeadroom(t *testing.T) { + if geometry.LabBigVolume { + t.Skip("a lab build only warns (TestLabBuildCreatesWithoutLocalHeadroom)") + } defer durable.SetRootFreeForTest(8 << 20)() for _, impl := range []durable.ImplName{durable.ImplWALStore, durable.ImplWALStoreChunk} { t.Run(string(impl), func(t *testing.T) { diff --git a/seaweed-block/core/geometry/volume_size.go b/seaweed-block/core/geometry/volume_size.go index 9259c2afca..f613cbabba 100644 --- a/seaweed-block/core/geometry/volume_size.go +++ b/seaweed-block/core/geometry/volume_size.go @@ -22,7 +22,10 @@ const MaxVolumeBytes uint64 = (16 << 40) - 4096 // in flight. Halved for the rest of the update (the HEAD write, the // manifest segments, a loaded or remote filer) and rounded down to a power // of two, that is 65,536 chunks. -const MaxNewVolumeBytes uint64 = 256 << 30 +// +// A lab build (the swblock_lab_bigvol tag, volume_size_lab.go) raises it to +// MaxVolumeBytes for scale rehearsals; a release build never carries that tag. +const MaxNewVolumeBytes uint64 = newVolumeCap // ErrVolumeTooLarge refuses a new volume above MaxNewVolumeBytes. var ErrVolumeTooLarge = errors.New("volume too large") diff --git a/seaweed-block/core/geometry/volume_size_lab.go b/seaweed-block/core/geometry/volume_size_lab.go new file mode 100644 index 0000000000..4bb6fab587 --- /dev/null +++ b/seaweed-block/core/geometry/volume_size_lab.go @@ -0,0 +1,12 @@ +//go:build swblock_lab_bigvol + +package geometry + +// newVolumeCap in a lab build is the format's own limit: the scale +// rehearsals create volumes above the release cap. Never a release build +// (CI refuses the tag in every image and release build). +const newVolumeCap uint64 = MaxVolumeBytes + +// LabBigVolume is true in a lab build: the release create cap is lifted and +// the local headroom check at create only warns. +const LabBigVolume = true diff --git a/seaweed-block/core/geometry/volume_size_lab_test.go b/seaweed-block/core/geometry/volume_size_lab_test.go new file mode 100644 index 0000000000..73dca4c221 --- /dev/null +++ b/seaweed-block/core/geometry/volume_size_lab_test.go @@ -0,0 +1,18 @@ +//go:build swblock_lab_bigvol + +package geometry + +import "testing" + +// A lab build lifts the create cap to the format's limit, and no further. +func TestLabBuildLiftsTheCreateCap(t *testing.T) { + if !LabBigVolume || MaxNewVolumeBytes != MaxVolumeBytes { + t.Fatalf("lab build: LabBigVolume %v, MaxNewVolumeBytes %d; want true and %d", LabBigVolume, MaxNewVolumeBytes, MaxVolumeBytes) + } + if err := ValidateNewVolumeSize(64 << 40); err == nil { + t.Fatal("64 TiB is above the format's limit and must stay refused") + } + if err := ValidateNewVolumeSize(10 << 40); err != nil { + t.Fatalf("10 TiB in a lab build: %v", err) + } +} diff --git a/seaweed-block/core/geometry/volume_size_release.go b/seaweed-block/core/geometry/volume_size_release.go new file mode 100644 index 0000000000..9e96c44bed --- /dev/null +++ b/seaweed-block/core/geometry/volume_size_release.go @@ -0,0 +1,10 @@ +//go:build !swblock_lab_bigvol + +package geometry + +// newVolumeCap is the release cap on a new volume (MaxNewVolumeBytes). +const newVolumeCap uint64 = 256 << 30 + +// LabBigVolume is false in a release build: the 256 GiB create cap and the +// local headroom check at create both hold. +const LabBigVolume = false diff --git a/seaweed-block/core/geometry/volume_size_release_test.go b/seaweed-block/core/geometry/volume_size_release_test.go new file mode 100644 index 0000000000..8aade22b0f --- /dev/null +++ b/seaweed-block/core/geometry/volume_size_release_test.go @@ -0,0 +1,12 @@ +//go:build !swblock_lab_bigvol + +package geometry + +import "testing" + +// A build without the lab tag keeps the release cap: 256 GiB. +func TestReleaseBuildKeepsTheCreateCap(t *testing.T) { + if LabBigVolume || MaxNewVolumeBytes != 256<<30 { + t.Fatalf("release build: LabBigVolume %v, MaxNewVolumeBytes %d; want false and 256 GiB", LabBigVolume, MaxNewVolumeBytes) + } +} diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 814a71adc9..68f8c2a6ee 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -959,7 +959,7 @@ Notes: | `INV-HOST-POOL-CONFIG-001` | A pool configuration is invisible until its complete synced temporary file is atomically renamed under the OS configuration lock. A killed initializer cannot leave a partial visible configuration that strands successors. | M7 configuration preparation/publication | `core/hostlimit` `publishConfig` | `TestKilledInitializerDoesNotPublishPartialConfiguration` | `HostBudget` NoPartialConfig/ConfigBeforeAdmission (filesystem atomicity checked natively) | ACTIVE | | `INV-HOST-URGENT-PENDING-001` | While an urgent cut holds its slot, or a caller holds HoldUrgentPending, every Normal admission on the host is refused with ErrUrgentPending (a held-slot wait); urgent admissions still run. | M7 host cut admission (Normal before a slot) | `core/hostlimit/limiter.go` `pool`, `Admit`; `core/hostlimit/pending.go` `HoldUrgentPending` | `TestNormalWaitsWhileUrgentPendingIsHeld`, `TestUrgentLeaseHoldsThePendingSignal` (`core/hostlimit/pending_test.go`); `TestSlotsUrgentAndJoinedRelease` (`core/hostlimit/limiter_test.go`) | — | ACTIVE | | `INV-HOST-LAUNCH-CHECK-001` | blockvolume refuses to start with a --host-limit-dir that is missing or not a directory, under a temporary directory, on a network file system, or already in use with different host-limit flags. | M7 host cut admission (process start) | `core/hostlimit/launch.go` `CheckLaunch`; `core/hostlimit/remotefs_linux.go`; `cmd/blockvolume/main.go` | `TestCheckLaunch` (`core/hostlimit/pending_test.go`) | — | ACTIVE | -| `INV-LOCAL-HEADROOM-001` | blockvolume refuses to create a volume when the durable root's free space is below the volume size plus its WAL, naming both numbers, before it creates the store, WAL or fresh marker, and warns at start when an existing volume's remaining sparse growth plus the WAL exceed the free space. | M1 open/create (durable provider start) | `core/frontend/durable/headroom.go`; `core/frontend/durable/provider.go` `createFresh`, `openExisting` | `TestCreateRefusesWithoutLocalHeadroom`, `TestOpenWarnsWithoutLocalHeadroom` (`core/frontend/durable/headroom_test.go`) | — | ACTIVE | +| `INV-LOCAL-HEADROOM-001` | blockvolume refuses to create a volume when the durable root's free space is below the volume size plus its WAL, naming both numbers, before it creates the store, WAL or fresh marker, and warns at start when an existing volume's remaining sparse growth plus the WAL exceed the free space. | M1 open/create (durable provider start) | `core/frontend/durable/headroom.go`; `core/frontend/durable/provider.go` `createFresh`, `openExisting` | `TestCreateRefusesWithoutLocalHeadroom`, `TestOpenWarnsWithoutLocalHeadroom` (`core/frontend/durable/headroom_test.go`) | A lab build (tag `swblock_lab_bigvol`, scale rehearsals only) warns instead of refusing (`TestLabBuildCreatesWithoutLocalHeadroom`); CI keeps the tag out of every image and release build (`.github/scripts/lab-tag-check.sh`) | ACTIVE | | `INV-CREATE-MAX-SIZE-001` | blockmaster refuses a new volume above `geometry.MaxNewVolumeBytes` at CreateVolume (InvalidArgument) and at a `--cluster-spec` start, with `ErrVolumeTooLarge` naming the size and the maximum, before any record or store exists. An existing volume keeps opening under `MaxVolumeBytes`. | create admission (CreateVolume, cluster-spec import) | `core/geometry/volume_size.go` `ValidateNewVolumeSize`; `core/lifecycle/store.go` `CreateVolume`; `cmd/blockmaster/cluster_spec.go` `loadClusterSpec`; `core/host/master/services.go` `CreateVolume` (restore geometry) | `TestCreateVolumeRefusesAVolumeAboveTheMaximum` (`core/host/master`), `TestClusterSpecRefusesAVolumeAboveTheMaximum` (`cmd/blockmaster`), `TestValidateNewVolumeSizeAtAndAboveTheMaximum` (`core/geometry`), `TestCreateVolumeRejectsBeyondUint32LBACap` (`core/lifecycle`) | — | ACTIVE | | `INV-HOST-SLOT-BUSY-CODE-001` | The chunk control API refuses a cut, snapshot or detach that host admission refused because every slot is held (or urgent work is pending) with 503 host_slot_busy, retryable; every other capture refusal keeps capture_refused. | M7 free → admitted (refused, wait) | `core/host/volume/chunk_control.go` `chunkErrorCode` | `TestHostSlotHeldHasItsOwnCode` (`core/host/volume/chunk_host_slot_code_test.go`) | — | ACTIVE | | `INV-CUT-INTENT-FIRST-001` | A cut or staging round begins (or replays) its holder session before any chunk or segment PUT. All upload waves use that session until commit. Payload I/O and pacing hold no adapter lock, so independent uploads and HEAD reads proceed. | M5 Begin → Upload → CAS | `core/storage/chunk_cut_payload.go` `streamCutPayloads`; `core/storage/chunk_layer.go` `captureLocked`, `stage`; `core/frontend/chunkstore/layout_remote.go` `LayoutRemote.Begin` | `TestSession_BegunBeforeFirstUploadAndClosedByCommit`, `TestSession_FailedBeginUploadsNothing` (`core/storage/chunk_layer_session_test.go`); `TestCutPayloadSessionBeginsIndependentOfCandidates`, `TestCutPayloadReadsOverlapEarlierUploadsWithinBudget` (`core/storage/chunk_review271_test.go`); `TestChunkPrecopy_StagedUploadsAreCoveredByIntents` (`core/storage/chunk_layer_precopy_test.go`); `TestLayoutRemoteUploadsOverlapWithoutBlockingHead`, `TestLayoutRemoteHeadReadDoesNotWaitForUpload` (`core/frontend/chunkstore/layout_upload_concurrency_test.go`) | `ChunkLifecycleFixed` `GCSafe`; `WorkspaceTakeover` `NoLiveIntentExpired` | ACTIVE |