Files
seaweedfs/weed/shell/command_volume_scrub_test.go
T
Chris LuandClaude Opus 5.5 80e0bf97dd shell: dial volume servers on their registered gRPC port in volume.scrub, ec.scrub, volume.server.state (#12315)
* shell: dial scrubbed volume servers on their registered gRPC port

volume.scrub, ec.scrub and volume.server.state built each data node's
address from its HTTP address alone, so a volume server whose gRPC port
is not the HTTP port + 10000 was dialed on the wrong port.

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

* shell: resolve -node volume servers to their registered gRPC port

An explicit -node/-nodes list was dialed on HTTP port + 10000 too.
Match each entry against the topology and take the data node's gRPC
port; an address the master does not know is used as given.

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

* shell: keep a gRPC port given in -node

A node given as host:port.grpcPort was rewritten to the registered gRPC
port; only a bare host:port takes it from the topology.

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

* shell: dial -node volume servers when the topology is unavailable

An explicit node list did not need the master before; keep using it as
given if the volume list cannot be fetched. Selecting every node still
requires the topology.

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

* shell: bound the topology lookup for an explicit -node list

With the master down, volumeServer.state -nodes waited on the master
forever instead of reaching the given volume servers. Give the lookup a
30s deadline and fall back to the addresses as given.

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

* shell: resolve volume server addresses from a topology-only listing

Only the data nodes are needed to find each server's gRPC port, so ask
the master for the topology without its volumes and ec shards. A large
cluster no longer risks running past the -node lookup deadline and
falling back to the HTTP port + 10000.

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

* shell: skip the topology lookup when every -node names its gRPC port

A host:port.grpcPort entry is dialed as given, so a list made only of
those does not need the master and no longer waits on it during an
outage.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 18:50:48 -08:00

55 lines
1.5 KiB
Go

package shell
import (
"reflect"
"testing"
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
)
func TestVolumeServerAddressesUseRegisteredGrpcPort(t *testing.T) {
dataNodes := []*master_pb.DataNodeInfo{
{Id: "10.0.0.1:8080", Address: "10.0.0.1:8080", GrpcPort: 18080},
{Id: "10.0.0.2:7000", Address: "10.0.0.2:7000", GrpcPort: 7500},
{Id: "10.0.0.3:8081"},
}
tests := []struct {
nodes string
wantGrpc []string
}{
{"", []string{"10.0.0.1:18080", "10.0.0.2:7500", "10.0.0.3:18081"}},
{"10.0.0.2:7000", []string{"10.0.0.2:7500"}},
{" 10.0.0.2:7000 ,,10.0.0.1:8080", []string{"10.0.0.2:7500", "10.0.0.1:18080"}},
{"10.0.0.9:7000.7600", []string{"10.0.0.9:7600"}},
{"10.0.0.2:7000.7600", []string{"10.0.0.2:7600"}},
}
for _, tt := range tests {
var gotGrpc []string
for _, addr := range volumeServerAddresses(dataNodes, tt.nodes) {
gotGrpc = append(gotGrpc, addr.ToGrpcAddress())
}
if !reflect.DeepEqual(gotGrpc, tt.wantGrpc) {
t.Errorf("volumeServerAddresses(%q) dials %v, want %v", tt.nodes, gotGrpc, tt.wantGrpc)
}
}
}
func TestEveryNodeNamesGrpcPort(t *testing.T) {
tests := []struct {
nodes string
want bool
}{
{"10.0.0.9:7000.7600", true},
{" 10.0.0.9:7000.7600 ,,[::1]:8080.18080", true},
{"10.0.0.9:7000.7600,10.0.0.2:7000", false},
{"10.0.0.2:7000", false},
{"volume.example.com", false},
{"volume.example.com:8080", false},
}
for _, tt := range tests {
if got := everyNodeNamesGrpcPort(tt.nodes); got != tt.want {
t.Errorf("everyNodeNamesGrpcPort(%q) = %v, want %v", tt.nodes, got, tt.want)
}
}
}