Files
seaweedfs/seaweed-block/cmd/blockmaster/journal_isolation_flags_test.go
T
pingqiuandClaude Opus 5.5 e57f399c07 feat: detect master journal sharing and alarm on lease headroom
A volume whose durable root sits on the authority store's file system
shares its jbd2 journal: under a WAL fsync storm the lease extensions
lag, grants clamp to the durable horizon and leases run out.

- core/storeident: (machine-id, st_dev) identity of a directory; unknown
  never matches.
- Heartbeats carry the durable root's identity (machine_id,
  durable_root_dev); the master compares it with its authority store,
  logs and counts co-located nodes once per detection.
- --strict-journal-isolation (default off = alarm only): refuses
  heartbeats of a co-located node that serves no volume (durable state
  decides), and refuses PlaceWorkspace/MoveWorkspace and new product-loop
  placements onto co-located nodes.
- Publisher: headroom alarm while an extension is pending and headroom
  < 1.125 TTL (before the first clamp), clamp counters (total, last
  minute), min headroom at grants, lazy per-minute summary;
  WorkspaceLeaseStats snapshot.
- --status-listen (loopback only): GET /status/workspace-lease JSON.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 02:10:44 -08:00

29 lines
1.1 KiB
Go

package main
import (
"strings"
"testing"
)
// --strict-journal-isolation and --status-listen are off by default; a
// non-loopback --status-listen is refused at startup with a clear error.
func TestParseFlags_JournalIsolationAndStatusListen(t *testing.T) {
f, err := parseFlags([]string{"--authority-store", t.TempDir()})
if err != nil {
t.Fatal(err)
}
if f.strictJournalIsolation || f.statusListen != "" {
t.Fatalf("defaults: strict=%v status-listen=%q, want off", f.strictJournalIsolation, f.statusListen)
}
f, err = parseFlags([]string{"--authority-store", t.TempDir(), "--strict-journal-isolation", "--status-listen", "127.0.0.1:9335"})
if err != nil || !f.strictJournalIsolation || f.statusListen != "127.0.0.1:9335" {
t.Fatalf("set: %+v %v", f, err)
}
for _, bad := range []string{"0.0.0.0:9335", ":9335", "192.168.1.10:9335"} {
_, err := parseFlags([]string{"--authority-store", t.TempDir(), "--status-listen", bad})
if err == nil || !strings.Contains(err.Error(), "must be a loopback address") {
t.Fatalf("--status-listen %s: %v, want a loopback refusal", bad, err)
}
}
}