From 767d498301df9da85aab02656aa647f01c848b92 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Tue, 1 Dec 2026 18:53:57 -0800 Subject: [PATCH] blockmaster: the node registry guard allows the host retire's removal After start the registry only loses entries: the operator's retire removes a host that holds no volume, and a retired id is then unregistered, so the identity checks only get stricter. Adders stay start-up only. Co-Authored-By: Claude Opus 5.5 --- .../blockmaster/node_registry_guard_test.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/seaweed-block/cmd/blockmaster/node_registry_guard_test.go b/seaweed-block/cmd/blockmaster/node_registry_guard_test.go index 08f6512bdc..77b785079e 100644 --- a/seaweed-block/cmd/blockmaster/node_registry_guard_test.go +++ b/seaweed-block/cmd/blockmaster/node_registry_guard_test.go @@ -11,11 +11,15 @@ import ( "testing" ) -// The node registry (server id -> registered host) is static after start: -// the identity checks (the registered-host refusal beside the certificate -// identity) assume no one rewrites it while blockmaster serves. Its only -// writer is the cluster-spec import at start-up. This guard fails when a -// new non-test caller of RegisterNode or RemoveNode appears anywhere. +// The node registry (server id -> registered host) only ever loses entries +// after start: the identity checks (the registered-host refusal beside the +// certificate identity) assume no one adds or rebinds a server id while +// blockmaster serves. Its only adder is the cluster-spec import at start-up. +// Its one remover after start is the operator's host retire, which takes +// only a host that holds no volume: a retired id is then unregistered, so a +// holder RPC under it is refused (refuseWorkspaceHolderHost) and the checks +// only get stricter. This guard fails when any other non-test caller of +// RegisterNode or RemoveNode appears anywhere. func TestNodeRegistryIsWrittenOnlyAtStartup(t *testing.T) { root, err := filepath.Abs(filepath.Join("..", "..")) if err != nil { @@ -64,8 +68,8 @@ func TestNodeRegistryIsWrittenOnlyAtStartup(t *testing.T) { t.Fatal(err) } sort.Strings(sites) - want := []string{"cmd/blockmaster/main.go:importLifecycleNodeInventory.RegisterNode"} + want := []string{"cmd/blockmaster/main.go:importLifecycleNodeInventory.RegisterNode", "core/host/master/format_gate.go:RetireHost.RemoveNode"} if strings.Join(sites, ",") != strings.Join(want, ",") { - t.Fatalf("node registry writers = %v, want only %v: a writer after start breaks the static-registry assumption of the identity checks", sites, want) + t.Fatalf("node registry writers = %v, want only %v: an adder after start, or another remover, breaks the identity checks' assumption", sites, want) } }