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 <noreply@anthropic.com>
This commit is contained in:
pingqiuandClaude Opus 5.5 committed 2026-12-01 18:53:57 -08:00
1 parent 9cf074d480
commit 767d498301
1 file changed
+11 -7
@@ -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)
}
}