mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-20 13:30:46 +02:00
pb: return empty server address for malformed grpc addresses
GrpcAddressToServerAddress used to return the unparseable input on a hostAndPort failure, so a malformed raft address (e.g. "host:abc") flowed into admin dashboard master maps unchanged. Return an empty string instead, skip empty conversions at the two raft-cluster merge sites, and drop the now-stale comment about the fatal exit the earlier commit removed.
This commit is contained in:
@@ -293,14 +293,17 @@ func (s *AdminServer) getMasterNodesStatus() []MasterNode {
|
||||
}
|
||||
raftCallSucceeded = true
|
||||
for _, server := range resp.ClusterServers {
|
||||
// pb.GrpcAddressToServerAddress calls glog.Fatalf on a parse
|
||||
// error, so pre-validate the raft address with net.SplitHostPort
|
||||
// and skip malformed entries instead of taking the process down.
|
||||
// Skip malformed raft addresses instead of letting an
|
||||
// unconvertible value into masterMap.
|
||||
if _, _, splitErr := net.SplitHostPort(server.Address); splitErr != nil {
|
||||
glog.Warningf("skip master with invalid raft address %q: %v", server.Address, splitErr)
|
||||
continue
|
||||
}
|
||||
httpAddress := pb.GrpcAddressToServerAddress(server.Address)
|
||||
if httpAddress == "" {
|
||||
glog.Warningf("skip master with invalid raft address %q", server.Address)
|
||||
continue
|
||||
}
|
||||
masterMap[httpAddress] = MasterNode{
|
||||
Address: httpAddress,
|
||||
IsLeader: server.IsLeader,
|
||||
|
||||
@@ -1351,6 +1351,9 @@ func (s *AdminServer) GetClusterMasters() (*ClusterMastersData, error) {
|
||||
for _, server := range resp.ClusterServers {
|
||||
// Raft stores gRPC addresses, convert to HTTP address
|
||||
httpAddress := pb.GrpcAddressToServerAddress(server.Address)
|
||||
if httpAddress == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
// Update existing master info or create new one
|
||||
if masterInfo, exists := masterMap[httpAddress]; exists {
|
||||
|
||||
@@ -564,7 +564,7 @@ func GrpcAddressToServerAddress(grpcAddress string) (serverAddress string) {
|
||||
host, grpcPort, parseErr := hostAndPort(grpcAddress)
|
||||
if parseErr != nil {
|
||||
glog.Errorf("server grpc address %s parse error: %v", grpcAddress, parseErr)
|
||||
return grpcAddress
|
||||
return ""
|
||||
}
|
||||
|
||||
port := int(grpcPort) - 10000
|
||||
|
||||
Reference in New Issue
Block a user