Files
seaweedfs/weed/server/master_grpc_admin_auth_coverage_test.go
Chris LuandClaude Opus 5.5 d2276f531e master: apply the whitelist to management gRPC RPCs (#13022)
* master: gate operator-only management RPCs on the whitelist

CollectionDelete, DisableVacuum, EnableVacuum, VolumeGrow,
ResumeVolumeGrowth, LeaseAdminToken and ReleaseAdminToken now call
checkGrpcAdminAuth, matching the whitelist their HTTP counterparts
already enforce. VolumeGrow stays open to the in-process growth loop,
and callers on the local gRPC socket of weed server/mini are local.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* master: admit unknown masters over KeepConnected only from the whitelist

A KeepConnected registration as a master pulls that address into the
raft quorum. Accept it from any caller only for this master and its
-peers; any other master address now needs a whitelisted caller, the
same check RaftAddServer applies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* master: test that every RPC is gated or listed with a reason

Port the volume server's coverage test so a new master RPC cannot skip
checkGrpcAdminAuth without an explicit exemption. The proto and AST
helpers now take the proto file and receiver name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume: admit callers on the local gRPC socket

weed server and weed mini route same-host gRPC dials through a unix
socket, whose peer address carries no IP. With -whiteList set the
volume server refused the in-process master's AllocateVolume, so no
volume could be grown. The Rust volume server serves gRPC over TCP only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* master: match a KeepConnected master against configured peers by gRPC endpoint

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* pb: bind the local gRPC socket for the owner only

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: warn when a deleted bucket's collection is left on the master

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* pb: bind the local gRPC socket in a private directory before moving it into place

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: report an unconfirmed bucket collection delete as such

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 08:27:35 -08:00

66 lines
2.6 KiB
Go

package weed_server
import (
"sort"
"testing"
)
// ungatedMasterRPCs are the Seaweed master RPCs that run without
// checkGrpcAdminAuth, each with the reason it stays open. As on the volume
// server the split is by caller: the whitelist holds masters, shell hosts and
// workers, while volume servers, filers, gateways and clients are not
// necessarily on it.
var ungatedMasterRPCs = map[string]string{
"SendHeartbeat": "volume servers register and report their volumes",
"Assign": "filers, gateways and clients assign file ids",
"StreamAssign": "filers assign file ids over a stream",
"LookupVolume": "every reader resolves volume locations",
"LookupEcVolume": "every reader resolves EC shard locations",
"VacuumVolume": "filer remote-cache eviction vacuums the volumes it emptied",
"VolumeMarkReadonly": "volume servers report their own read-only state",
"GetMasterConfiguration": "volume servers, filers and gateways load cluster settings at startup",
"Ping": "liveness probe; targets are limited to known peers",
"Statistics": "read-only usage, the filer's statfs",
"CollectionList": "read-only, filers and S3 gateways list collections",
"CollectionStatistics": "read-only, S3 bucket size metrics",
"VolumeList": "read-only topology",
"VolumeListStream": "read-only topology",
"ListClusterNodes": "read-only cluster membership",
"GetAdminLockStatus": "read-only admin lock holder",
"RaftListClusterServers": "read-only raft membership",
}
func TestMasterAdminAuthCoverage(t *testing.T) {
declared := rpcNamesFromProto(t, "master.proto")
if len(declared) < 25 {
t.Fatalf("parsed only %d RPCs from the proto, expected the full service", len(declared))
}
gated := gatedServerMethods(t, "MasterServer")
declaredSet := make(map[string]struct{}, len(declared))
for _, rpc := range declared {
declaredSet[rpc] = struct{}{}
_, exempt := ungatedMasterRPCs[rpc]
switch {
case gated[rpc] && exempt:
t.Errorf("%s calls checkGrpcAdminAuth but is also listed in ungatedMasterRPCs", rpc)
case !gated[rpc] && !exempt:
t.Errorf("%s does not call checkGrpcAdminAuth and is not listed in ungatedMasterRPCs; "+
"gate it, or add it with the reason it must stay open", rpc)
}
}
var stale []string
for rpc := range ungatedMasterRPCs {
if _, ok := declaredSet[rpc]; !ok {
stale = append(stale, rpc)
}
}
sort.Strings(stale)
for _, rpc := range stale {
t.Errorf("ungatedMasterRPCs lists %q, which is not an RPC in master.proto", rpc)
}
}