Files
seaweedFS/weed/worker/tasks/util/address.go
Chris Lu 998c8d2702 Worker maintenance tasks now use non-default grpcPort if configured (#8407)
Fixes #8401

When creating balance/vacuum tasks, the worker maintenance scheduler was
accidentally discarding the custom grpcPort defined on the DataNodeInfo
by using just its HTTP Address string, which defaults to +10000
during grpc dialing.

By using pb.NewServerAddressFromDataNode, the grpcPort suffix is correctly
encoded in the server address string, preventing connection refused errors
for users running volume servers with custom gRPC ports.
2026-02-22 22:40:14 -08:00

24 lines
817 B
Go

package util
import (
"fmt"
"github.com/seaweedfs/seaweedfs/weed/admin/topology"
"github.com/seaweedfs/seaweedfs/weed/pb"
)
// ResolveServerAddress resolves a server ID to its network address using the active topology
func ResolveServerAddress(serverID string, activeTopology *topology.ActiveTopology) (string, error) {
if activeTopology == nil {
return "", fmt.Errorf("topology not available")
}
allNodes := activeTopology.GetAllNodes()
nodeInfo, exists := allNodes[serverID]
if !exists {
return "", fmt.Errorf("server %s not found in topology", serverID)
}
// Note: We use NewServerAddressFromDataNode here because it encodes the GRPC port into the server address
// if it is non-zero, avoiding the default +10000 GRPC port offset.
return string(pb.NewServerAddressFromDataNode(nodeInfo)), nil
}